Skip to content
Nana UI

QR Code

Renders a QR code as crisp, scalable SVG. Encodes any text (byte mode, UTF-8) with a self-contained generator — no runtime dependencies. Choose a module style with variant, theme it with CSS custom properties, and drop a logo into the center via the default slot.

Terminal window
npm install @nana-tec/ui-components
import "@nana-tec/ui-components/qr-code";
<nana-qr-code value="https://design.nanatec.co.ke"></nana-qr-code>

The variant attribute changes how modules are drawn — square (default), rounded, or dots. (The demos below set explicit colors so they stay crisp in both light and dark; by default the module color follows your theme.)

Override the colour tokens to brand the code. Keep strong contrast between foreground and background so it stays scannable.

Higher levels (Q, H) tolerate more damage or occlusion — required if you overlay a center logo.

For a simple text monogram, set the logo attribute — the badge is styled for you (defaults to the module color, white text, rounded), tunable via CSS variables. For a custom image, slot an <img> instead. Always pair either with error-correction="H" so the code stays scannable behind the overlay.

<!-- Monogram — styled automatically -->
<nana-qr-code value="https://nanatec.co.ke" logo="N" error-correction="H"></nana-qr-code>
<!-- Or slot a custom logo image -->
<nana-qr-code value="https://nanatec.co.ke" error-correction="H">
<img src="/logo.svg" alt="Nanatec" />
</nana-qr-code>
PropertyTypeDefaultDescription
valuestring''The data to encode
sizenumber160Rendered size in pixels (width and height)
variant'square' | 'rounded' | 'dots''square'Module shape style
errorCorrection'L' | 'M' | 'Q' | 'H''M'Error-correction level (higher tolerates more damage / occlusion)
marginnumber4Quiet-zone width, in modules
labelstring''Accessible label (defaults to the encoded value)
logostring''Short monogram rendered as a styled center badge automatically
SlotDescription
(default)Optional center logo / overlay (e.g. an &lt;img>). Use a high error-correction level so the code stays scannable.
VariableDefaultDescription
--nana-qr-foregroundModule colour
--nana-qr-backgroundBackground / quiet-zone colour
--nana-qr-radiusFrame corner radius
--nana-qr-logo-sizeLogo width / monogram tile size (default 22% / 2.25rem)
--nana-qr-logo-bgMonogram tile background (default: the module colour)
--nana-qr-logo-colorMonogram text colour (default #fff)
--nana-qr-logo-radiusMonogram tile corner radius (default 0.5rem)
PartDescription
frameThe bordered background frame
svgThe SVG element
modulesThe <path> of dark modules
logoThe center logo / monogram container
Explore QR Code interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook