1. framework components
  2. ›
  3. qr code

QR Code

Render scannable QR codes with a frame, overlay, pattern, and download trigger.

Frame Colors

Use brand color for the frame and a contrasting fill for the QR pattern.

Overlay

Demonstrates an overlay with an icon and a contrasting square background to separate it visually from the pattern.

Skeleton Logo

Clickable Download

Wrap the visual frame/pattern in the download trigger so clicking the code initiates a download.

Anatomy

Here’s an overview of how the QrCode component is structured in code:

tsx
import { QrCode } from "@skeletonlabs/skeleton-react";

export default function Anatomy() {
	return (
		<QrCode value="https://skeleton.dev">
			<QrCode.Frame>
				<QrCode.Pattern />
			</QrCode.Frame>
			<QrCode.Overlay />
			<QrCode.DownloadTrigger />
		</QrCode>
	);
}

API Reference

Root

PropDefaultType
value—string | undefined

The controlled value to encode.

defaultValue—string | undefined

The initial value to encode when rendered. Use when you don't need to control the value of the qr code.

ids—ElementIds | undefined

The element ids.

encoding—QrCodeGenerateOptions | undefined

The qr code encoding options.

onValueChange—((details: ValueChangeDetails) => void) | undefined

Callback fired when the value changes.

pixelSize—number | undefined

The pixel size of the qr code.

dir"ltr""ltr" | "rtl" | undefined

The document's text/writing direction.

getRootNode—(() => ShadowRoot | Node | Document) | undefined

A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.

element—((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Provider

PropDefaultType
value—QrCodeApi<PropTypes>

element—((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Context

PropDefaultType
children—(qrCode: QrCodeApi<PropTypes>) => ReactNode

DownloadTrigger

PropDefaultType
mimeType—DataUrlType

The mime type of the image.

quality—number | undefined

The quality of the image.

fileName—string

The name of the file.

element—((attributes: HTMLAttributes<"button">) => Element) | undefined

Render the element yourself

Frame

PropDefaultType
element—((attributes: HTMLAttributes<"svg">) => Element) | undefined

Render the element yourself

Pattern

PropDefaultType
element—((attributes: HTMLAttributes<"path">) => Element) | undefined

Render the element yourself

Overlay

PropDefaultType
element—((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

View page on GitHub