QRCode
A QR code drawn as one SVG path, encoded in the browser with no service and no dependency: sharp at any size, printable, and named for a screen reader.
Import
import { QRCode } from '@vitral/vue';Basic
Type and the code follows. It picks the smallest version that holds the text, and the densest mode — digits, capitals or bytes — that the text allows.
Size and colour
`size` is any CSS length. Keep `color` darker than `background`: most phone cameras will not read a light code on a dark ground.
A logo in the middle
With an `image` the code is encoded at level H, which survives losing 30% of it, so the logo hides nothing a reader needs. `imageSize` is its width against the code's.
API
Read from packages/vue/src/components/QRCode/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| value * | string | What the code says: a link, a Wi-Fi setting, any text. |
| ecc | 'L' | 'M' | 'Q' | 'H' | How much of the code can be lost and still read: `L` 7%, `M` 15%, `Q` 25%, `H` 30%. Defaults to `M`, and to `H` with an `image` over it. |
| margin | number | Light squares around the code, which a reader needs to find it. Defaults to 4. |
| size | string | Any CSS length; the theme's (`10rem`) otherwise. |
| color | string | The dark squares' colour. Keep it darker than `background`, or phones will not read it. |
| background | string | — |
| image | string | A logo in the middle. |
| imageSize | number | The logo's width, as a share of the code's. Defaults to 0.22. |
| label | string | Names the code for a screen reader; the value it holds otherwise. |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.