A flexible QR code generator with theme integration, custom styling, error handling, and advanced dot customization built with the qr-code-styling library.
Overview
The QR Code component bridges physical and digital experiences by generating scannable codes that connect users to websites, contact information, or any digital content. It features automatic theme integration, advanced dot styling, corner customization, and error handling, making it essential for marketing materials, business cards, and any application requiring quick digital access. Perfect for improving user onboarding and reducing friction in offline-to-online conversion funnels.
Installation
pnpm dlx shadcn@latest add https://deltacomponents.dev/r/qr-code.json
Usage
1import QRCode from "@/registry/media/qr-code"23export function Component() {4 return (5 <QRCode6 value="https://deltacomponents.dev"7 size={200}8 dotStyle="rounded"9 cornerSquareStyle="extra-rounded"10 cornerDotStyle="rounded"11 />12 )13}
API Reference
Props
Prop | Type | Default | Description |
---|---|---|---|
value | string | - | The data to encode in the QR code (required) |
size | number | 200 | Size of the QR code in pixels |
bgColor | string | "--color-background" | Background color (CSS variable or color value) |
fgColor | string | "--color-foreground" | Foreground color (CSS variable or color value) |
level | "L" | "M" | "Q" | "H" | "M" | Error correction level |
marginSize | number | 0 | Margin around the QR code |
className | string | "" | Additional CSS classes for the container |
dotStyle | "rounded" | "dots" | "classy" | "classy-rounded" | "square" | "extra-rounded" | "square" | Style of the QR code data dots |
cornerSquareStyle | "dot" | "square" | "extra-rounded" | "rounded" | "dots" | "classy" | "classy-rounded" | "square" | Style of the corner positioning squares |
cornerDotStyle | "dot" | "square" | "rounded" | "dots" | "classy" | "classy-rounded" | "extra-rounded" | "square" | Style of the dots inside corner squares |
Examples
Advanced Styling
QR codes with advanced dot styling and corner customization.
Custom Colors
QR code with custom primary color styling.
Styling Options
Dot Styles
The dotStyle
prop allows you to customize the appearance of the QR code data dots:
square
- Standard square dots (default)rounded
- Rounded corner dots for a softer lookdots
- Circular dots for a modern appearanceclassy
- Elegant curved dotsclassy-rounded
- Combination of classy and rounded stylesextra-rounded
- Heavily rounded dots for maximum softness
Corner Square Styles
The cornerSquareStyle
prop controls the appearance of the three positioning squares:
square
- Standard square corners (default)dot
- Circular corner squaresrounded
- Rounded corner squaresextra-rounded
- Heavily rounded corner squaresdots
- Dotted corner squaresclassy
- Elegant curved corner squaresclassy-rounded
- Combination of classy and rounded corner styles
Corner Dot Styles
The cornerDotStyle
prop customizes the dots inside the corner positioning squares:
square
- Standard square dots (default)dot
- Circular dotsrounded
- Rounded corner dotsdots
- Multiple small dotsclassy
- Elegant curved dotsclassy-rounded
- Combination of classy and rounded dot stylesextra-rounded
- Heavily rounded dots
Theme Integration
The component automatically uses shadcn/ui theme colors by default, providing seamless integration with your design system:
Default Theme-Aware Behavior
By default, QR codes automatically adapt to light/dark themes:
1// Automatic theme adaptation (default behavior)2<QRCode value="https://example.com" />3// Background: --color-background4// Foreground: --color-foreground
Custom Color Options
You can override the default colors with any CSS variable or color value:
1// Custom primary color2<QRCode3 value="https://example.com"4 fgColor="--color-primary"5/>67// Custom background and foreground8<QRCode9 value="https://example.com"10 bgColor="--color-card"11 fgColor="--color-card-foreground"12/>1314// Direct color values15<QRCode16 value="https://example.com"17 bgColor="#ffffff"18 fgColor="#000000"19/>2021// Branded colors22<QRCode23 value="https://example.com"24 bgColor="--color-muted"25 fgColor="--color-primary"26/>
Available Theme Variables
--color-background
/--color-foreground
(default)--color-card
/--color-card-foreground
--color-primary
/--color-primary-foreground
--color-secondary
/--color-secondary-foreground
--color-muted
/--color-muted-foreground
--color-accent
/--color-accent-foreground