- Accordion
- Action Bar
- Alert Dialog
- Alert
- Announcement
- Aspect Ratio
- Autocomplete
- Avatar
- Badge
- Bottom Navigation
- Breadcrumb
- Button Group
- Button
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Circular Progress
- Circular Slider
- Clipboard
- Collapsible
- Color Picker
- Combobox
- Command
- Context Menu
- Data List
- Date Picker
- Dialog
- Drawer
- Editable
- Field
- File Upload
- Float
- Floating Panel
- Frame
- Hint
- Hover Card
- Image Cropper
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Link Overlay
- Listbox
- Marquee
- Menu
- Native Select
- Number Input
- Pagination
- Popover
- Progress
- Prose
- QR Code
- Radio Group
- Rating
- Resizable
- Scroll Area
- Segment Group
- Select
- Separator
- Sheet
- Sidebar
- Signature Pad
- Skeleton
- Skip Nav
- Slider
- Spinner
- Status
- Steps
- Switch
- Table
- Tabs
- Textarea
- Timer
- Toast
- Toggle Group
- Toggle Tooltip
- Toggle
- Tooltip
- Tour
- Tree View
Installation
pnpm dlx shadcn@latest add https://shark.vini.one/r/qr-code.json
Usage
import { QrCode, QrCodeFrame, QrCodeOverlay, QrCodeDownload, } from "@/components/ui/qr-code";
<QrCode> <QrCodeFrame /> <QrCodeOverlay /> <QrCodeDownload /> </QrCode>
Size
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
Examples
With an overlay
Use <QrCodeOverlay /> to add an overlay in the center.
Error correction
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:
- L: Allows recovery of up to 7% data loss (default)
- M: Allows recovery of up to 15% data loss
- Q: Allows recovery of up to 25% data loss
- H: Allows recovery of up to 30% data loss
L
M
Q
H
Download
Use <QrCodeDownload /> with fileName and mimeType to let users download the QR code as an image.
Live Preview
API Reference
QrCode
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) |
QrCodeFrame
SVG containing the QR pattern. Scales with size.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | - |
QrCodeOverlay
Optional center overlay (e.g. logo) on top of the QR pattern.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | - |
QrCodeDownload
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.