docs/components/qr-code
Sections
Components
Utilities
Forms
Hooks
Copy Markdown
Displays a QR code.
PreviewCode
CLIManual
pnpmbunnpmyarn
pnpm dlx shadcn@latest add @shark/qr-code
QrCode
├── QrCodeFrame
├── QrCodeOverlay
└── QrCodeDownload
import {
QrCode,
QrCodeFrame,
QrCodeOverlay,
QrCodeDownload,
} from "@/components/ui/qr-code";
<QrCode>
<QrCodeFrame />
<QrCodeOverlay />
<QrCodeDownload />
</QrCode>
Override the size with the --qr-code-size CSS variable on QrCode
For example, --qr-code-size:6rem for small, --qr-code-size:10rem for large
PreviewCode
Use QrCodeOverlay to add an overlay in the center.
PreviewCode
In cases where the link is too long or the logo overlay covers a significant area, the error correction level can be increased.
Use the encoding.ecc property to set the error correction level:
PreviewCode
L
M
Q
H
Use QrCodeDownload with fileName and mimeType to let users download the QR code as an image.
PreviewCode
Live Preview
PNGSVG
Root wrapper for the QR code and optional overlay/actions.
| Prop | Type | Default |
|---|---|---|
value | string | - |
defaultValue | string | - |
onValueChange | (details: ValueChangeDetails) => void | - |
encoding | QrCodeGenerateOptions | - |
pixelSize | number | - |
className | string | - |
asChild | boolean | - |
| Attribute | Default |
|---|---|
--qr-code-size | --spacing(32) |
--qr-code-overlay-size | calc(var(--qr-code-size)/4) |
SVG containing the QR pattern. Scales with size.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | - |
Optional center overlay on top of the QR pattern.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | - |
Downloads the QR code as an image file.
| Prop | Type | Default |
|---|---|---|
fileName | string | - |
mimeType | DataUrlType | - |
quality | number | - |
className | string | - |
asChild | boolean | - |
For a complete list of props, see the Ark UI documentation.
[
Previous page
Prose ](/docs/components/prose)[
Next page
Radio Group ](/docs/components/radio-group)
On This Page
InstallationAnatomyUsageSizeExamplesWith an overlayError correctionDownloadAPI ReferenceQrCodeQrCodeFrameQrCodeOverlayQrCodeDownload