QRdx

shadcn/ui registry

Add a QR code component with download buttons, or an image-based QR scanner, to a shadcn/ui project with one command.

QRdx publishes a shadcn/ui registry with two components built on the qrdx library. The shadcn CLI copies the source into your project, so you own the code and can change it.

QR code

npx shadcn@latest add https://qrdx.dev/r/qr-code.json

This adds components/qr-code.tsx and installs qrdx.

import { QrCode } from "@/components/qr-code";

export function ShareCard() {
  return (
    <QrCode
      value="https://qrdx.dev"
      size={180}
      fgColor="#155DFC"
      bodyPattern="rounded"
      cornerEyePattern="rounded"
      caption="Scan to open qrdx.dev"
    />
  );
}

It renders the code as an SVG with an accessible name, plus PNG and SVG download buttons.

Props

PropTypeDefaultDescription
valuestringrequiredText or URL to encode
sizenumber200Rendered width and height in pixels
fgColor, bgColorColorConfig#000000, #FFFFFFColors: any CSS color or a qrdx gradient
eyeColor, dotColorColorConfigfgColorCorner eye and eye dot colors
bodyPatternBodyPatterncircleData module shape
cornerEyePatternCornerEyePatterngearCorner eye frame shape
cornerEyeDotPatternCornerEyeDotPatterncircleCorner eye dot shape
levelErrorLevelQError correction. Use H with a logo
marginnumber2Quiet zone around the code, in modules
templateIdstring—Frame template, e.g. Arrow
logostring—Center logo: a data URL or an image URL served with CORS headers
labelstringQR code: <value>Accessible name for screen readers
captionReactNode—Visible caption under the code
downloadFormatsDownloadFormat[]["png", "svg"]Download buttons to show. Pass [] to hide them
downloadSizenumber1024Width and height of downloaded files, 50 to 5000
filenamestringqr-codeDownload file name without extension

Any other prop is passed to the wrapping <figure>. downloadFormats also accepts jpg and pdf; PDF downloads need the optional jspdf package (npm install jspdf).

QR code scanner

npx shadcn@latest add https://qrdx.dev/r/qr-code-scanner.json

This adds components/qr-code-scanner.tsx: a drop zone that reads a QR code from an image the user drops or picks. Decoding runs in the browser, so the image never leaves the device. It reads image files only, not a live camera feed.

"use client";

import { QrCodeScanner } from "@/components/qr-code-scanner";

export function ScanUpload() {
  return <QrCodeScanner onResult={(value) => console.log(value)} />;
}
PropTypeDefaultDescription
onResult(value: string) => void—Called with the decoded text
labelstringScan a QR code from an imageHeading inside the drop zone

The result is shown with a copy button, and with an "Open link" button when it is an http or https URL.

Using the registry namespace

To install with a short name, add the registry to your components.json:

{
  "registries": {
    "@qrdx": "https://qrdx.dev/r/{name}.json"
  }
}
npx shadcn@latest add @qrdx/qr-code @qrdx/qr-code-scanner

Styling

Both components use Tailwind classes with the standard shadcn/ui theme tokens (bg-background, border-input, text-muted-foreground, ring-ring), so they follow your theme and dark mode. They don't depend on other shadcn components.

Last updated on

On this page