QRCode
SVG QR code, dark on white in both themes, with an optional centre icon and loading / expired states.
import { QRCode } from '@lobehub/ui/base-ui';Data Display
Basic
Loading preview
APIs
QRCode properties
bgColorstringDefaults to
"#fff".borderedbooleanDefaults to
true.colorstringDefaults to
"#000".errorLevel'L' | 'M' | 'Q' | 'H'Defaults to
"M".iconnull | string | number | bigint | false | true | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode>onRefresh() => voidrefnull | (instance: HTMLDivElement | null) => void | (() => VoidOrUndefinedOnly) | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES] | RefObject<HTMLDivElement | null>Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
sizenumberDefaults to
160.status'active' | 'loading' | 'expired'Defaults to
"active".valueRequiredstring
Also accepts all native HTML and ARIA attributes.
The code stays dark on white in dark mode so phones can scan it; color and bgColor override that. Setting icon raises the error correction level to H and clears the modules under the icon. status="expired" shows a Refresh button when onRefresh is set.
Migrating from antd QRCode
- Drop
color="#000",bgColor="#fff"andbordered={false}where they only restated the old workaround; keepbordered={false}if you want no outline. type="canvas"is not supported; output is always SVG.
Helpful?