Skip to content

QR Code

<loomi-qrcode> renders a real QR code from a URL or short text value. It includes optional scanner-style corner brackets, a gradient fill, and an animated scan beam.

Terminal window
npm install @loomidev/qrcode lit
import "@loomidev/qrcode";
<loomi-qrcode
url="https://loomiui.com"
corner-borders
gradient
gradient-scan
></loomi-qrcode>
<loomi-qrcode url="https://example.com"></loomi-qrcode>
<loomi-qrcode
url="https://example.com/pay/invoice-245"
size="260"
error-correction="H"
corner-borders
corner-border-color="var(--loomi-success-600)"
gradient
gradient-from="var(--loomi-success-600)"
gradient-to="var(--loomi-warning-500)"
gradient-scan
></loomi-qrcode>
<loomi-qrcode
url="https://example.com/table/12"
gradient-scan
scan-count="2"
></loomi-qrcode>

For the library-wide baseline, see Foundations — Accessibility.

For the shared container and viewport rules, see Foundations — Responsive behavior.

For theme activation, token overrides, and contrast guidance, see Foundations — Dark mode.

AttributeTypeDefaultDescription
urlstring""URL to encode. Takes precedence over value.
valuestring""Text to encode when url is not set.
sizenumber220Rendered square size in pixels. Minimum visual size is 96px.
error-correction"L" | "M" | "Q" | "H""M"QR error correction level — see Error correction levels below.
quiet-zonenumber4Number of light modules around the QR matrix.
foregroundstringvar(--loomi-text)Solid module color when gradient is off.
backgroundstringvar(--loomi-surface)QR background color.
radius"none" | "small" | "medium" | "large" | "full""medium"Outer frame radius.
gradientbooleanfalseFill QR modules with a diagonal gradient.
gradient-fromstringvar(--loomi-primary-600)Gradient start color.
gradient-tostringvar(--loomi-warning-500)Gradient end color.
module-radiusnumber0Radius for each dark module, from 0 to 0.5.
corner-bordersbooleanfalseShow scanner-style corner brackets.
corner-border-colorstringvar(--loomi-primary-600)Corner bracket color.
corner-border-widthstring4pxCorner bracket stroke width.
corner-border-lengthstring34pxLength of each bracket arm.
gradient-scanbooleanfalseShow an animated scan gradient over the QR code.
scan-colorstringrgba(14, 165, 233, 0.72)Scan beam color.
scan-durationstring2.4sDuration of one full scan sweep (down and back up).
scan-countnumber | "infinite""infinite"How many times the scan beam sweeps down and back up. Set a positive integer to stop after that many passes, or leave as "infinite" to loop forever.
aria-labelstringgeneratedAccessible label for the rendered QR image.

The error-correction attribute controls how much of the QR code can be damaged, obscured, or covered by a logo while remaining scannable. Higher levels add more redundancy at the cost of a denser (and for very long values, larger) code:

LevelRecovery capacityWhen to use
L (Low)~7%Clean digital display with no overlays; maximizes data capacity for long URLs.
M (Medium)~15%Balanced default that works well for most use cases.
Q (Quartile)~25%Printed materials that may get scuffed, folded, or dirty (packaging, stickers).
H (High)~30%Best resilience; recommended whenever you overlay a logo or use corner-borders / gradient visual effects on top of the modules.

The encoder supports byte-mode QR codes through version 10, which covers typical URLs and short payloads. For longer values, shorten the URL before encoding.

  • @loomidev/core