Skip to main content
Urbicon UI

QRCodebeta

Renders any text or URL as a scannable QR code. SVG output from a from-scratch ISO/IEC 18004 encoder — no runtime dependency. Completes the auth package's zero-dependency 2FA story.

Playground

Error correction
Size
Frame
Loading...
Loading syntax highlighting...

01 Examples

Basic — encode a URL

Pass any string to value. The card frame sits the code on a guaranteed-light surface so it scans reliably in any theme.
Loading...
Loading syntax highlighting...

Error-correction levels

L≈7%, M≈15%, Q≈25%, H≈30% of the code can be damaged or occluded and still decode. Higher recovery packs in more modules — watch the pattern grow denser from L to H.
L
M
Q
H
Loading...
Loading syntax highlighting...

Sizes

size is the rendered edge length in pixels. The matrix stays crisp at any size — it is a single scalable SVG path.
120px
160px
220px
Loading...
Loading syntax highlighting...

Custom colours

foreground and background accept any CSS colour string (they are functional colour props, not palette classes). Keep a high-contrast dark-on-light pairing so scanners stay reliable.
Loading...
Loading syntax highlighting...

02 2FA & auth

QRCode completes the auth package's zero-dependency 2FA story. Instead of wiring an external QR library into TwoFactorManager's qr snippet, hand the otpauth:// enrolment URI straight to <QRCode> — an authenticator app (Google Authenticator, 1Password, …) scans it to register the shared TOTP secret.

Use errorCorrection="H" here: the extra recovery data keeps the code readable when it is scanned at an angle or from a distance across a second device. And never echo the secret into aria-label — the visible code already carries it, while the label is announced aloud and surfaced in the accessibility tree.

Encode an otpauth:// enrolment URI

High error correction, a comfortable scan size, and the card frame for a guaranteed-light ground.
Loading...
Loading syntax highlighting...

03 Encoding capacity & errors

The encoder picks the smallest QR version (1–40) that fits and the most efficient mode for your data — numeric, alphanumeric, or UTF-8 byte — automatically. You never choose a version by hand.

Bound the size with maxVersion when a code has to stay physically small. Data that overflows that bound triggers onError and renders a visible fallback instead of throwing through the render, so the surrounding page stays up. Try it below: type past the maxVersion=4 capacity and the code swaps to its fallback.

Live capacity demo

The bound value flows straight into the QR matrix. onError logs; the built-in fallback communicates the failure to the user.
Loading...
Loading syntax highlighting...

04 Accessibility

  • Renders as role="img" with an aria-label — defaulting to a localized "QR code" and overridable per instance.
  • Never echo sensitive payloads (a 2FA secret, a signed token) into aria-label: it is announced aloud and exposed in the accessibility tree.
  • For guaranteed scannability keep high-contrast dark-on-light modules. frame="card" supplies the light ground; the default foreground is currentColor, so an unframed code inherits the surrounding text colour.
  • When encoding fails, the visible fallback also carries role="img" with the same label, so assistive tech is never left with an empty region.

05 API Reference

16 props
16 props 1 required

No matching properties

No matching properties

06 Installation

Import

Loading...
Loading syntax highlighting...