QR Code
Generate accessible, themeable QR codes locally as crisp SVG graphics.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
value | string | — | Text or URL encoded by the QR code. |
size | number | 200 | Rendered width and height in CSS pixels. Set to 0 to use --c2-qr-code--size. |
error-correction | QrCodeErrorCorrection | M | Error correction level: L (7%), M (15%), Q (25%), or H (30%). |
margin | number | 4 | Quiet-zone width measured in QR modules. Four is recommended for reliable scanning. |
boost-error-correction | boolean | false | Raises error correction when the encoded version has spare capacity. |
aria-label | string | null | null | Accessible name announced for the generated image. Defaults to QR code. |
Slots
| Name | Description |
|---|---|
center | Optional logo or mark centered over the code. Prefer error-correction="H" and keep the mark small so the code remains scannable. |
Events
| Name | Type | Description |
|---|---|---|
qr-code-error | CustomEvent<QrCodeErrorEventDetail> | Fired when the value cannot be encoded. detail contains the error and rejected value. |
CSS custom properties
Grouped by semantic target and state from --c2-component__target__state--property. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-qr-code--size | pixel | 200px | |
--c2-qr-code__module--color | color | #18181b | |
--c2-qr-code__background--color | color | #ffffff | |
--c2-qr-code__container--border-radius | border-radius | 8px | |
--c2-qr-code__placeholder--color | color | #71717a | |
--c2-qr-code__placeholder--font-size | font-size | 12px | |
--c2-qr-code__center--size | length | 20% | |
--c2-qr-code__center--background-color | color | #ffffff | |
--c2-qr-code__center--padding | padding | 4px | |
--c2-qr-code__center--border-radius | border-radius | 6px | |