Skip to content

QR Code ​

A QR code display component powered by @vielzeug/sigil. Encodes the value payload into an inline SVG: themeable via currentColor, crisp at any scale, and requiring no canvas or external library. Payloads that exceed QR capacity render an error state and emit error instead of throwing.

Variants ​

Flat (Default) ​

Transparent background; module color inherits currentColor. Works on any surface.

PreviewCode
RTL
html
<ore-qr-code value="https://vielzeug.dev"></ore-qr-code>

Card ​

Themed background surface with the component's border radius. Preferred when the code sits on a busy or colored backdrop: scanners need a light quiet zone.

PreviewCode
RTL
html
<ore-qr-code value="https://vielzeug.dev" variant="card"></ore-qr-code>

Sizes ​

size accepts the named scale or any pixel value.

PreviewCode
RTL
html
<ore-qr-code value="https://vielzeug.dev" size="sm"></ore-qr-code>
<ore-qr-code value="https://vielzeug.dev" size="md"></ore-qr-code>
<ore-qr-code value="https://vielzeug.dev" size="lg"></ore-qr-code>
<ore-qr-code value="https://vielzeug.dev" size="96"></ore-qr-code>
sizeRendered edge
sm128 px
md192 px
lg256 px
numberThat many px

Error Correction ​

Higher levels tolerate more damage (logos, print wear) at the cost of a denser matrix. The encoder picks the smallest QR version that fits automatically.

PreviewCode
RTL
html
<ore-qr-code value="https://vielzeug.dev" error-correction="L"></ore-qr-code>
<ore-qr-code value="https://vielzeug.dev" error-correction="H"></ore-qr-code>
LevelRecoveryUse for
L~7%Dense codes, clean media
M~15%Default
Q~25%Print
H~30%Overlaid logos, harsh conditions

Caption Slot ​

PreviewCode
RTL
html
<ore-qr-code value="mesh://offer/abc123" variant="card">
  <span slot="caption">Scan to pair</span>
</ore-qr-code>

Events ​

html
<ore-qr-code value="https://vielzeug.dev" id="qr"></ore-qr-code>

<script type="module">
  const qr = document.getElementById('qr');
  qr.addEventListener('render', (e) => console.log('version', e.detail.version));
  qr.addEventListener('error', (e) => console.warn(e.detail.error.message));
</script>

Custom Styling ​

html
<ore-qr-code
  value="https://vielzeug.dev"
  style="--qr-code-dark: var(--color-primary); --qr-code-radius: var(--rounded-lg)">
</ore-qr-code>

API Reference ​

Attributes ​

AttributeTypeDefaultDescription
valuestring''The payload to encode
error-correction'L' | 'M' | 'Q' | 'H''M'Error-correction level
marginnumber4Quiet-zone width in modules
size'sm' | 'md' | 'lg' | number'md'Rendered edge length
labelstring'QR code'Accessible name of the SVG
variant'flat' | 'card''flat'Surface variant
rounded'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | 'full''md'Border radius

Events ​

EventDetailDescription
render{ version: number; size: number }Emitted after each successful encode
error{ error: SigilError }Emitted when encoding fails (e.g. capacity)

Slots ​

SlotDescription
captionOptional caption below the code

CSS Parts ​

PartElementDescription
wrapper<div>Outer container
svg<span>Rendered SVG container
caption<span>Caption slot container
error<div>Error-state container

CSS Custom Properties ​

PropertyDescriptionDefault
--qr-code-darkModule colorcurrentColor
--qr-code-lightModule backgroundtransparent
--qr-code-sizeRendered edge (overrides size)size-derived px
--qr-code-radiusBorder radius (overrides rounded)var(--rounded-md)
--qr-code-paddingInner padding around the matrixvar(--size-3)
--qr-code-bgCard background (variant="card")var(--color-canvas)
--qr-code-borderCard border width (variant="card")var(--border)
--qr-code-border-colorCard border color (variant="card")var(--color-divider)
--qr-code-shadowCard box shadow (variant="card")var(--shadow-sm)
--qr-code-error-colorError-state text colorvar(--text-color-secondary)

Accessibility ​

The SVG carries role="img" with aria-label from label and a <title> element: give label a meaningful description of what the code does ("Pairing code", "Wi-Fi join code"), not the payload itself. The error state uses role="alert". On dark surfaces prefer variant="card" or set --qr-code-light so the quiet zone keeps contrast for scanners.