Encodes a link or text into a code that a phone can scan.
Scan to open the component library.
The CLI adds the files, packages, theme variables, and Tailwind plugin that this component uses. Before you run it, set up your project.
QrCodeRootOwns the encoded value. QrCode adds the frame, pattern, overlay, and download button.
QrCodeFrameQrCodePattern
QrCodeOverlayOptionalWrap it with QrCodeFrame in a relative element when the root holds other parts. Set encoding ecc to H.
QrCodeDownloadTriggerOptional
QrCodeContext Renders a function with the qr code api: value, setValue, and getDataUrl.
overlay sets the error correction to H, so the code still scans under the logo.
Scan to open the installation guide.
The file has a white surface and a quiet zone, so it scans on any background.
Also install Text field.
https://vip-ui.dev/components/qr-code
QrCode
- value: string
- The value to encode, controlled.
- defaultValue: string
- The value to encode at first, uncontrolled.
- size: "sm" | "md" | "lg" = "md"
- The size of the code in the page.
- label: string = "QR code"
- The accessible name of the code.
- overlay: { src: string; alt?: string }
- A logo centered over the code. Sets the error correction to H unless `encoding` overrides it.
- download: boolean | { fileName?: string; mimeType?: string; quality?: number } = false
- Shows a download button with PNG, JPEG, or SVG output.
- pixelSize: number = 10
- The pixel size of one module.
- encoding: QrCodeGenerateOptions
- The encoding options, such as `ecc` and `boostEcc`.
- onValueChange: (details: { value: string }) => void
- Called when the encoded value changes.
- children: ReactNode
- Renders below the code, such as a caption.
- dir: "ltr" | "rtl"
- Sets the writing direction.
- ids: ElementIds
- Sets the ids of the qr code parts.
- getRootNode: () => Node
- Resolves the document in custom environments such as iframes.
QrCodeRoot
Owns the encoded value and renders the root. Compose the frame, pattern, overlay, and trigger inside it.
- children: ReactNode
- The composed parts.
QrCodeFrame
Renders the code on a white surface with a quiet zone. The download keeps both.
- label: string = "QR code"
- The accessible name of the code.
QrCodePattern
Draws the modules with `fill-current`.
QrCodeOverlay
Centers its children in the nearest positioned element. Wrap it with the frame in a `relative` element when the root holds other parts.
- children: ReactNode
- The logo image.
QrCodeDownloadTrigger
Downloads the code. The file includes the overlay when it renders.
- fileName: string = "qr-code.png"
- The name of the downloaded file.
- mimeType: "image/png" | "image/jpeg" | "image/svg+xml" = "image/png"
- The image type of the downloaded file.
- quality: number
- The quality of a lossy download, from 0 to 1.
- variant: ButtonVariant = "outline"
- The visual emphasis of the trigger.
- size: "xs" | "sm" | "md" | "lg" | "xl" = "sm"
- The size of the trigger.
- children: ReactNode
- Replaces the default "Download" label.