āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā š shadcn/directory/sadmann7/diceui/components/qr-code ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
npx shadcn@latest add "https://diceui.com/r/qr-code"
```package-install
@radix-ui/react-slot qrcode
```
</Step>
<Step>
Install the type definitions:
```package-install
@types/qrcode
```
</Step>
<Step>
Copy and paste the following code into your project.
<ComponentSource name="qr-code" />
</Step>
</Steps>
Import the parts, and compose them together.
import { QRCode } from "@/components/ui/qr-code";
<QRCode value="https://example.com">
<QRCode.Canvas />
</QRCode>
Render QR codes as Canvas, SVG, or Image elements.
<ComponentTabs name="qr-code-formats-demo" />Customize colors, size, and error correction levels.
<ComponentTabs name="qr-code-customization-demo" />The main container component that provides context for QR code generation.
<AutoTypeTable path="./types/docs/qr-code.ts" name="RootProps" />
<CSSVariablesTable variables={[ { title: "--qr-code-size", description: "The size of the QR code in pixels. Used to constrain child elements to the QR code dimensions.", defaultValue: "Based on size prop (e.g., 200px)", }, ]} />
Renders the QR code as an HTML image element.
<AutoTypeTable path="./types/docs/qr-code.ts" name="ImageProps" />
Renders the QR code using HTML5 Canvas.
<AutoTypeTable path="./types/docs/qr-code.ts" name="CanvasProps" />
Renders the QR code as an SVG element.
<AutoTypeTable path="./types/docs/qr-code.ts" name="SvgProps" />
A button component for downloading the QR code.
<AutoTypeTable path="./types/docs/qr-code.ts" name="DownloadProps" />
<KeyboardShortcutsTable shortcuts={[ { keys: ["Enter"], description: "Activates the download button when focused.", }, { keys: ["Space"], description: "Activates the download button when focused.", }, ]} />
QR codes support different error correction levels that determine how much of the code can be damaged while still being readable:
Higher error correction levels result in denser QR codes but provide better resilience to damage or distortion.
--qr-code-size CSS variable to prevent layout issuesā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā