Client component
QR Code
Client-side SVG QR codes with logo overlays, lifecycle states and download.
"use client";
import { QrCode } from "astralis-ui";
export function QrCodeDemo() {
return <QrCode value="https://astralis.dev" size="md" />;
}size
errorLevel
status
import { QrCode } from "astralis-ui";
<QrCode
value="https://astralis-ui.com"
/>
Import#
import { QrCode } from "astralis-ui";Overlays and states#
overlay centers a logo on the code (raise errorLevel to "H" so the
covered modules stay scannable). The status prop covers the login-QR
lifecycle: loading, expired (with a refresh action), and scanned.
overlay + download
A
expired → refresh
Expired
scanned
Scanned!
"use client";
import { useState } from "react";
import { QrCode, Center, Text, HStack, VStack } from "astralis-ui";
export function QrCodeStates() {
const [expired, setExpired] = useState(true);
return (
<HStack gap="6" wrap="wrap" alignItems="start" justifyContent="center">
<VStack gap="1" alignItems="start">
<Text as="span" size="xs" color="muted">overlay + download</Text>
<QrCode
value="https://astralis.dev/docs"
size="sm"
errorLevel="H"
downloadable
overlay={
<Center bg="inverted" size="full" rounded="sm">
<Text as="span" size="xs" color="inverted" weight="bold">A</Text>
</Center>
}
/>
</VStack>
<VStack gap="1" alignItems="start">
<Text as="span" size="xs" color="muted">expired → refresh</Text>
<QrCode
value="https://astralis.dev/session"
size="sm"
status={expired ? "expired" : "active"}
onRefresh={() => setExpired(false)}
/>
</VStack>
<VStack gap="1" alignItems="start">
<Text as="span" size="xs" color="muted">scanned</Text>
<QrCode value="https://astralis.dev" size="sm" status="scanned" />
</VStack>
</HStack>
);
}Props#
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | None | The text or URL to encode. Required. |
size | "sm" | "md" | "lg" | "xl" | "md" | Preset sizes from 96 to 280px. |
pixelSize | number | None | Explicit size in pixels, overriding the preset. |
errorLevel | "L" | "M" | "Q" | "H" | "M" | Error correction, from 7% to 30% recoverable. Go higher when an overlay covers modules. |
color / bgColor | string | "#000000" / "transparent" | CSS colors of the modules and the background. |
overlay / overlaySize | ReactNode / number | None / 20 | A centered logo, sized as a percentage of the code. |
status | "active" | "loading" | "expired" | "scanned" | "active" | Lifecycle overlay. |
onRefresh | () => void | None | Shows a Refresh button on the expired overlay. |
downloadable | boolean | false | Adds a button that downloads the code as an SVG. |
downloadFileName | string | "qrcode" | File name for the download, without the extension. |