Skip to content
Nana UI

QR Code

View .md Download

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>

Properties

PropertyAttributeTypeDefaultDescription
errorCorrectionerror-correctionQrCodeErrorCorrection'M'Error-correction level (higher tolerates more damage / occlusion)
labelstring''Accessible label (defaults to the encoded value)
logostring''Short monogram (e.g. "N") rendered as a styled center badge automatically. Prefer this over the slot for simple text logos.
marginnumber4Quiet-zone width, in modules
sizenumber160Rendered size in pixels (width and height)
valuestring''The data to encode
variantQrCodeVariant'square'Module shape style

Slots

SlotDescription
(default)Optional center logo / overlay (e.g. an `<img>`). Use a high `error-correction` level so the code stays scannable. For a simple monogram, use the `logo` attribute instead — the badge is styled for you.

CSS parts

PartDescription
::part(frame)The bordered background frame
::part(svg)The SVG element
::part(modules)The `<path>` of dark modules
::part(logo)The center logo/monogram container

CSS custom properties

PropertyDescription
--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)
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