QRCode
QRCode encodes a URL or payload for handoff to another device.
@duskmoon-dev/components/qr-code Usage
When to use
- Use it to clarify state, metadata, content hierarchy, or loading without creating a new workflow.
- Pair it with semantic content so visual treatment never becomes the only source of meaning.
Implementation notes
Features
Focuses on status, metadata, empty/loading states, or content grouping without owning application state.
Uses DuskMoon tokens so the component follows the active docs theme.
QRCode is most often configured through `value`, `type`, `size`, `icon`.
Renders a canvas-style qr code by default
Feature Demos
Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.
Basic usage
Import the component stylesheet and QRCode from its package subpath, then render it with the core props.
import "@duskmoon-dev/components/styles.css";
import { QRCode } from "@duskmoon-dev/components/qr-code";
export function Example() {
return (<QRCode
value="https://duskmoon.dev/components"
size={160}
color="#111827"
bgColor="#ffffff"
/>);
} Renders a canvas-style qr code by default
test-backedQRCode scenario from the component test coverage: renders a canvas-style qr code by default.
import "@duskmoon-dev/components/styles.css";
import { QRCode } from "@duskmoon-dev/components/qr-code";
export function QRCodeRendersACanvasStyleDemo() {
return (<QRCode
value="https://duskmoon.dev/components"
size={160}
color="#111827"
bgColor="#ffffff"
/>);
} Supports svg type, size, color, background, and border control
test-backedQRCode scenario from the component test coverage: supports svg type, size, color, background, and border control.
import "@duskmoon-dev/components/styles.css";
import { QRCode } from "@duskmoon-dev/components/qr-code";
export function QRCodeSupportsSvgTypeSizeDemo() {
return (<QRCode
value="https://duskmoon.dev/components"
size={160}
color="#111827"
bgColor="#ffffff"
/>);
} Renders icon and expired refresh action
test-backedQRCode scenario from the component test coverage: renders icon and expired refresh action.
import "@duskmoon-dev/components/styles.css";
import { QRCode } from "@duskmoon-dev/components/qr-code";
export function QRCodeRendersIconAndExpiredDemo() {
return (<QRCode
value="https://duskmoon.dev/components"
size={160}
color="#111827"
bgColor="#ffffff"
/>);
} Supports loading and scanned status classes
test-backedQRCode scenario from the component test coverage: supports loading and scanned status classes.
import "@duskmoon-dev/components/styles.css";
import { QRCode } from "@duskmoon-dev/components/qr-code";
export function QRCodeSupportsLoadingAndScannedDemo() {
return (<QRCode
value="https://duskmoon.dev/components"
size={160}
color="#111827"
bgColor="#ffffff"
/>);
} Theme aware
Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.
<div data-theme="sunshine">
<QRCode
value="https://duskmoon.dev/components"
size={160}
color="#111827"
bgColor="#ffffff"
/>
</div>
<div data-theme="moonlight">
<QRCode
value="https://duskmoon.dev/components"
size={160}
color="#111827"
bgColor="#ffffff"
/>
</div> API
The API reference below lists every parsed exported type or interface for QRCode. Start with `value`, `type`, `size`, `icon` for common usage.
packages/components/src/components/qr-code/QRCode.types.ts
Scenarios: packages/components/src/components/qr-code/QRCode.test.tsx | Prop | Type | Required | Description |
|---|---|---|---|
value | string | No | value configures QRCode. |
type | QRCodeType | No | type configures QRCode. |
size | number | No | size configures QRCode. |
icon | string | ReactNode | No | icon configures QRCode. |
iconSize | number | No | iconSize configures QRCode. |
status | QRCodeStatus | No | status configures QRCode. |
errorLevel | QRCodeErrorLevel | No | errorLevel configures QRCode. |
color | string | No | color configures QRCode. |
bgColor | string | No | bgColor configures QRCode. |
bordered | boolean | No | bordered configures QRCode. |
onRefresh | () => void | No | onRefresh configures QRCode. |
"canvas" | "svg" "active" | "expired" | "loading" | "scanned" "L" | "M" | "Q" | "H"