- Accordion
- Alert Dialog
- Alert
- Autocomplete
- Avatar
- Badge
- Button Group
- Button
- Card
- Carousel
- Chart
- Checkbox
- Clipboard
- Collapsible
- Combobox
- Command
- Context Menu
- Date Picker
- Dialog
- Editable
- Field
- File Upload
- Floating Panel
- Hover Card
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Marquee
- Menu
- Native Select
- Number Input
- Pagination
- Popover
- Progress
- QR Code
- Radio Group
- Rating Group
- Scroll Area
- Select
- Separator
- Sheet
- Skeleton
- Slider
- Spinner
- Splitter
- Steps
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle Group
- Toggle
- Tooltip
- Tour
- Tree View
Installation
pnpm dlx shadcn@latest add @shark-ui/qr-code
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 a 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 element. Renders a div.
| Prop | Type | Default |
|---|---|---|
value | string | — |
defaultValue | string | — |
onValueChange | (details: ValueChangeDetails) => void | — |
encoding | QrCodeGenerateOptions | — |
pixelSize | number | — |
asChild | boolean | — |
className | string | — |
| Attributes | Type | Default |
|---|---|---|
[data-slot] | - | qr-code |
--qr-code-size | string | var(--spacing(32)) |
--qr-code-overlay-size | string | calc(var(--qr-code-size)/3) |
QrCodeFrame
SVG frame that contains the QR pattern. Renders an svg.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | — |
className | string | — |
QrCodeOverlay
Overlay in the center of the QR code (e.g. logo). Renders a div.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | — |
className | string | — |
QrCodeDownload
Trigger to download the QR code as an image. Renders a button.
| Prop | Type | Default |
|---|---|---|
fileName | string | — |
mimeType | DataUrlType | — |
quality | number | — |
asChild | boolean | — |
For a complete list of props, see the Ark UI documentation.