Component reference
QRCode
Create a QR code from an editable value.
Preview
Live previewOptional six-digit hex. Clear to restore the preset. Check contrast with your brand color.
Changes apply to this preview only.
37 character(s) · UTF-8 byte mode
Why SVG?
A vector path stays sharp at any size, prints cleanly and needs no image pipeline.
- Versions 1–10 cover roughly 271 bytes at level L and 119 bytes at level H.
- Levels trade capacity for resilience: H survives more damage.
- The quiet zone defaults to four modules and can be changed with margin.
- No logo overlay: scanners are more reliable without one.
Width adapts to the available space
"use client";
import {
Input,
QRCode,
Card,
CardHeader,
CardTitle,
CardDescription,
CardContent
} from "@pimolu/react";
import { useState } from "react";
export function DemoExample() {
const [value, setValue] = useState("https://pimolu.dev/components/qr-code");
return (
<div
className="grid grid-cols-[repeat(auto-fit,minmax(min(100%,280px),1fr))] gap-6 min-w-0 items-start"
>
<div className="grid gap-5 min-w-0">
<Input
label="Value"
value={value}
onValueChange={setValue}
helperText={`${value.length} character(s) · UTF-8 byte mode`}
placeholder="https://pimolu.dev"
/>
{
value.trim()
? (<QRCode
value={value}
size={220}
level="M"
aria-label="QR code for the current value"
/>)
: (<p
className="text-sm text-muted"
>Enter at least one character to draw a code.</p>)
}
</div>
<Card>
<CardHeader>
<CardTitle>Why SVG?</CardTitle>
<CardDescription>
A vector path stays sharp at any size, prints cleanly and needs
no image pipeline.
</CardDescription>
</CardHeader>
<CardContent>
<ul className="text-sm text-muted">
<li>
Versions 1–10 cover roughly 271 bytes at level L and 119 bytes
at level H.
</li>
<li>Levels trade capacity for resilience: H survives more damage.</li>
<li>
The quiet zone defaults to four modules and can be changed with
margin.
</li>
<li>No logo overlay: scanners are more reliable without one.</li>
</ul>
</CardContent>
</Card>
</div>
);
}More examples
Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.
Error correction levels
The same payload at L, M, Q and H. Higher levels add Reed-Solomon codewords and can increase the version, but tolerate more damage.
Colors and size
Keep a strong dark-on-light contrast for cameras. The light background is part of the symbol, so transparency is not recommended.
Real-world payloads
A URL, a contact card and an email action all fit in a single code. The vCard is plain text with line breaks encoded as bytes.
Usage
Validate the target destination and choose an appropriate size/error-correction level.
API reference
Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.
PimoluQRCodeMatrix
Type source| Name | Type | Default | Description |
|---|---|---|---|
sizeRequired | number | 160 | Edge length in modules, including no quiet zone. |
versionRequired | number | — | QR version, from 1 to 10. |
maskRequired | number | — | Mask applied to the data modules. |
levelRequired | PimoluQRCodeLevel | "M" | Error correction level. |
modulesRequired | boolean[][] | — | `modules[row][column]`, true for a dark module. |
sizeRequirednumberDefault: 160
Edge length in modules, including no quiet zone.
versionRequirednumberNo default extracted.
QR version, from 1 to 10.
maskRequirednumberNo default extracted.
Mask applied to the data modules.
levelRequiredPimoluQRCodeLevelDefault: "M"
Error correction level.
modulesRequiredboolean[][]No default extracted.
`modules[row][column]`, true for a dark module.
PimoluQRCodeProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
valueRequired | string | — | Text encoded in byte mode as UTF-8. Must not be empty. |
size | string | number | undefined | 160 | Rendered width/height. Defaults to 160. |
level | PimoluQRCodeLevel | undefined | "M" | Error correction level. Defaults to "M". |
darkColor | string | undefined | "#000000" for scanner reliability | Module color. Defaults to "#000000" for scanner reliability. |
lightColor | string | undefined | "#ffffff" | Background color. Defaults to "#ffffff". |
margin | number | undefined | 4 and is clamped to 0–16 | Quiet zone in modules. Defaults to 4 and is clamped to 0–16. |
mask | number | undefined | — | Force a mask (0–7) instead of choosing the lowest-penalty one. Mostly useful to reproduce a reference encoder or to test determinism. |
title | string | undefined | — | Optional SVG `<title>` tooltip. |
aria-label | string | undefined | `title`, then "QR code" | Accessible name. Defaults to `title`, then "QR code". |
className | string | undefined | — | Class applied to the `<svg>`. |
style | CSSProperties | undefined | — | Inline style applied to the `<svg>`. |
valueRequiredstringNo default extracted.
Text encoded in byte mode as UTF-8. Must not be empty.
sizestring | number | undefinedDefault: 160
Rendered width/height. Defaults to 160.
levelPimoluQRCodeLevel | undefinedDefault: "M"
Error correction level. Defaults to "M".
darkColorstring | undefinedDefault: "#000000" for scanner reliability
Module color. Defaults to "#000000" for scanner reliability.
lightColorstring | undefinedDefault: "#ffffff"
Background color. Defaults to "#ffffff".
marginnumber | undefinedDefault: 4 and is clamped to 0–16
Quiet zone in modules. Defaults to 4 and is clamped to 0–16.
masknumber | undefinedNo default extracted.
Force a mask (0–7) instead of choosing the lowest-penalty one. Mostly useful to reproduce a reference encoder or to test determinism.
titlestring | undefinedNo default extracted.
Optional SVG `<title>` tooltip.
aria-labelstring | undefinedDefault: `title`, then "QR code"
Accessible name. Defaults to `title`, then "QR code".
classNamestring | undefinedNo default extracted.
Class applied to the `<svg>`.
styleCSSProperties | undefinedNo default extracted.
Inline style applied to the `<svg>`.
Accessibility
- Always provide the encoded destination as readable text or a link, not only a visual code.