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" />;
}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">
<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">
<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">
<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 | required | The text or URL to encode. |
size | "sm" | "md" | "lg" | "xl" | "md" | Preset pixel sizes (96–280px). |
pixelSize | number | — | Explicit size, overriding the preset. |
errorLevel | "L" | "M" | "Q" | "H" | "M" | Error correction (7–30%); go high with overlays. |
color / bgColor | CSS colors | "#000" / transparent | Module and background colors. |
overlay / overlaySize | ReactNode / number | — / 20 | Centered logo, sized as % of the code. |
status | "active" | "loading" | "expired" | "scanned" | "active" | Lifecycle overlay. |
onRefresh | () => void | — | Shows a Refresh button on the expired overlay. |
downloadable / downloadFileName | boolean / string | false / "qrcode" | SVG download button. |