QR Code
ProNewA scannable QR code drawn by the bundled encoder from a supplied value, with dot styles, a central logo, frames, caption and PNG download.
Installation
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
Props
| Prop | Type | Default |
|---|---|---|
| value* | stringThe link or text to encode. | — |
| size | numberWidth of the code in pixels. It shrinks to fit a narrower container. | 168 |
| errorCorrection | QRErrorCorrectionHow much damage the code survives: `L` 7%, `M` 15%, `Q` 25%, `H` 30%. Defaults to `H` with a logo and `M` without. | — |
| dots | DotsShape of the data modules. | "square" |
| eyes | EyesShape of the three corner markers. | "square" |
| foreground | stringColor of the modules. Keep it much darker than `background`, or phones will not read the code. | "#0a0a0a" |
| background | stringColor behind the modules. | "#ffffff" |
| color | stringColor of the frame and the caption. | "var(--primary)" |
| textColor | stringColor of the caption text on top of `color`. | "var(--primary-foreground)" |
| logo | React.ReactNodeA logo for the centre: an image URL, or a node such as a `BrandIcon`. | — |
| logoSize | numberShare of the code's width that the logo covers, up to 0.3. | 0.22 |
| quietZone | numberEmpty modules kept around the code. | 2 |
| frame | "none" | "border" | "solid" | "banner" | "phone"`border` outlines the code, `solid` mats it, `banner` puts a large caption beside it and `phone` draws a handset. | "none" |
| caption | stringThe call to action: "Scan me", "Get the app". | — |
| captionIcon | React.ReactNodeAn icon shown before the caption. | — |
| captionStyle | "bubble" | "bar" | "text"`bubble` points at the code, `bar` is fused to the frame, `text` is plain. | "bubble" |
| captionSide | "bottom" | "top" | "left"Where the caption sits. Ignored by the `banner` and `phone` frames. | "bottom" |
| href | stringTurns the caption into a link, for visitors who are already on their phone. | — |
| download | booleanAdds a button that saves the code as a PNG. | false |
| fileName | stringFile name of the saved PNG, without the extension. | "qr-code" |
| onDownload | () => voidCalled once the PNG has been saved. | — |
| label | stringAccessible name of the code. Defaults to the caption, or the encoded value. | — |
| className | string | — |
Accessibility
- The code is one image named after its caption or the value it encodes.
- Pass a web, phone, SMS, email or local `href` to make the caption a link; unsafe caption targets render as text.
- The download button announces “Saved” or “Could not save” politely.
- Empty and too-long values show a message instead of a broken code. The fade-in is skipped under reduced motion.