BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/spell-ui/qr-code

QR Code

spell-ui/qr-code
FreeComponent

QR code generator with rounded finder patterns and dot-style data modules.

Live preview

live · rendered by the registry
Rendered by spell-ui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://spell.sh/r/qr-code.json

Source

registry/spell-ui/qr-code.tsxspell.sh/r/qr-code.json
1"use client";
2
3import * as React from "react";
4import QRCodeLib from "qrcode";
5import { cn } from "@/lib/utils";
6
7interface QRCodeProps extends React.SVGProps<SVGSVGElement> {
8 value: string;
9 size?: number;
10 fgColor?: string;
11 bgColor?: string;
12 errorCorrectionLevel?: "L" | "M" | "Q" | "H";
13 className?: string;
14}
15
16function isInFinderPattern(row: number, col: number, size: number): boolean {
17 return (
18 (row < 7 && col < 7) ||
19 (row < 7 && col >= size - 7) ||
20 (row >= size - 7 && col < 7)
21 );
22}
23
24export function QRCode({
25 value,
26 size = 268,
27 fgColor = "var(--foreground)",
28 bgColor = "var(--background)",
29 errorCorrectionLevel = "M",
30 className,
31 ...props
32}: QRCodeProps) {
33 const qrData = React.useMemo(() => {
34 try {
35 return QRCodeLib.create(value, { errorCorrectionLevel });
36 } catch {
37 return null;
38 }
39 }, [value, errorCorrectionLevel]);
40
41 if (!qrData) {
42 return null;
43 }
44
45 const moduleCount = qrData.modules.size;
46 const moduleSize = size / moduleCount;
47 const totalSize = size;
48 const circleRadius = moduleSize * (1 / 3);
49
50 const finderPositions: [number, number][] = [
51 [0, 0],
52 [0, moduleCount - 7],
53 [moduleCount - 7, 0],
54 ];
55
56 const finderSize = 7 * moduleSize;
57 const innerPadding = moduleSize;
58 const innerWhiteSize = 5 * moduleSize;
59 const innerBlackSize = 3 * moduleSize;
60
61 const circles: { cx: number; cy: number }[] = [];
62
63 for (let row = 0; row < moduleCount; row++) {
64 for (let col = 0; col < moduleCount; col++) {
65 if (qrData.modules.get(row, col) && !isInFinderPattern(row, col, moduleCount)) {
66 circles.push({
67 cx: (col + 0.5) * moduleSize,
68 cy: (row + 0.5) * moduleSize,
69 });
70 }
71 }
72 }
73
74 return (
75 <svg
76 width={totalSize}
77 height={totalSize}
78 viewBox={`0 0 ${totalSize} ${totalSize}`}
79 xmlns="http://www.w3.org/2000/svg"
80 aria-label={`QR code for ${value}`}
81 className={cn("block", className)}
82 {...props}
83 >
84 <rect width={totalSize} height={totalSize} fill={bgColor} rx="12" ry="12" />
85 {finderPositions.map(([r, c]) => {
86 const x = c * moduleSize;
87 const y = r * moduleSize;
88 return (
89 <g key={`${r}-${c}`}>
90 <rect
91 x={x}
92 y={y}
93 width={finderSize}
94 height={finderSize}
95 fill={fgColor}
96 rx="12"
97 ry="12"
98 />
99 <rect
100// … truncated

What it pulls in

npm packages

  • qrcode

Files it writes

  • registry/spell-ui/qr-code.tsx

Facts

Registry
spell-ui
Type
registry:component
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-03
Last confirmed
today

Go to the source

Docs on spell-ui spell.sh xxtomm/spell-ui on GitHub Raw registry item This item as JSON

More from spell-ui

All 33 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Animated Checkboxanimated-checkboxspell-uiComponentsFree1 dep
Animated Gradientanimated-gradientspell-uiComponentsFreeno deps
Badgebadgespell-uiComponentsFree2 deps
Bars Spinnerbars-spinnerspell-uiComponentsFreeno deps
Blur Revealblur-revealspell-uiComponentsFree1 dep
Chartchartspell-uiComponentsFreeno deps
Color Selectorcolor-selectorspell-uiComponentsFreeno deps
Copy Buttoncopy-buttonspell-uiComponentsFree1 dep
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex