---
title: "QR Code"
description: "A QR code that a phone camera reads, for a link, a Wi-Fi login, or short text. It can hold your logo and show the link with a Copy button."
url: https://gelatinui.com/components/qr-code
markdown_url: https://gelatinui.com/components/qr-code.md
access: free
install: "npx shadcn@latest add @gelatin-ui/qr-code"
registry_item: https://gelatinui.com/r/qr-code.json
version: "2026-11-17"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# QR Code

> A QR code that a phone camera reads, for a link, a Wi-Fi login, or short text. It can hold your logo and show the link with a Copy button.

Page: https://gelatinui.com/components/qr-code

## When to use it

Best for: A link or a short text that a person moves from a screen to a phone camera.

- Use it to move a link or a short text from a screen to a phone.
- Add `QrCodeCaption` so people who cannot scan can read and copy the value.
- Give a code that is not a link a `label`. The default name does not read other values aloud, because some hold secrets.
- Add a logo with `QrCodeLogo`. The error correction then goes to H, so the code still reads.

## When not to use it

- For a product code that a store scanner reads, use a [Barcode](https://gelatinui.com/components/barcode.md).

## Notes for agents

- Add `QrCodeCaption` so people who cannot scan can read and copy the value.
- A logo (`QrCodeLogo`) raises the error correction to H, so the code still reads.

## Anatomy

```text
QrCode
├─ QrCodeLogo (0..n)
└─ QrCodeCaption (0..n)
```

## API reference

### QrCode

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `aria-label` | `string` |  | Defines a string value that labels the current element. The accessible name. Default "QR code", or "QR code: <value>" for an http(s) link: other payloads are noise read aloud, and some hold secrets (a Wi-Fi password, an `otpauth://` key). |
| `value` | `string` |  | The text in the code: a link, a Wi-Fi payload (`wifiPayload` in `#/lib/qr-payload`), any text. |
| `pixelSize` | `number` | 160 | The outer width in px, quiet zone included. Default 160. |
| `level` | `QrCodeLevel` |  | The error correction level: L 7%, M 15% (default), Q 25%, H 30% of the code can be lost. A logo always sets H. |
| `module` | `"dots" \| "rounded" \| "square"` | "square" | The shape of the data modules. Default `square`. |
| `finder` | `"circle" \| "rounded" \| "square"` | "square" | The shape of the three finder patterns. Default `square`. |
| `plate` | `boolean` | true | The light plate under the code. Default true. |
| `status` | `DataStatus` | "ready" | The load state. Default `ready`. `loading`: the skeleton while the value is not known yet. `empty`: the empty box. `error` shows as `ready`: the error box is for a value the code cannot hold. |
| `animateIn` | `boolean` | false | Sweeps the modules in when the code mounts in the browser. Default false. |
| `labels` | `Partial<CodeSymbolLabels>` |  | The texts of the empty and error states. |
| `onError` | `function` |  | Runs when etiket cannot encode the value, with the kind and the message. |

### QrCodeImage

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `ReactNode` |  | A `QrCodeLogo`: its box is cleared in the center of the code. |
| `logoSize` | `number` | QR_LOGO_MAX | The logo box as a part of the code width. Default and maximum 0.22. |

### QrCodeLogo

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### QrCodeCaption

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `copy` | `boolean` |  | The Copy Button after the value. Default true when there are no children. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| QrCode | `qr-code` |  |  |  |
| QrCodeLogo | `qr-code-logo` |  |  |  |
| QrCodeCaption | `qr-code-caption` |  | `--qr-code-size` |  |

## Usage

The value is the text in the code: a link or any text. Give a value that is not an http(s) link a `label`, because the default name does not read it aloud.

```tsx title="share-project.tsx"
import { QrCode, QrCodeCaption, QrCodeImage, QrCodeLogo } from "@/components/labels/qr-code";

export function ShareProject() {
  return (
    <QrCode value="https://acme.com/projects/atlas" pixelSize={200} module="rounded" finder="rounded" animateIn>
      <QrCodeImage>
        <QrCodeLogo>
          <img src="/logo.svg" alt="" />
        </QrCodeLogo>
      </QrCodeImage>
      <QrCodeCaption />
    </QrCode>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/qr-code
```

It adds 40 registry items: 37 files, 5985 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@xstate/react`, `clsx`, `etiket`, `motion`, `tailwind-merge`, `tailwind-variants`, `xstate`.

## Built on

- [Copy Button](https://gelatinui.com/components/copy-button.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Data Matrix Code](https://gelatinui.com/components/data-matrix-code.md)
- [Copy Button](https://gelatinui.com/components/copy-button.md)
- [Barcode](https://gelatinui.com/components/barcode.md)

## Accessibility

The root is a plain `<figure>`, not `role="img"`, so a screen reader can still reach the caption and its button.

The SVG carries the name with `aria-label`: "QR code", or "QR code: <value>" for an http(s) link. Other values can hold secrets, such as a Wi-Fi password, so they are not read. Pass `label` to set your own name.

`QrCodeCaption` shows the value as text for people who cannot scan, with a Copy Button named "Copy". The button has a 44px target on touch (`hit-area`). The value text is `dir="ltr"`, so a link reads left to right on a right-to-left page.

## Motion

| Part | Motion |
| --- | --- |
| Reveal (with `animateIn`) | panel · 260ms · ease-panel (0.2, 0.4, 0.2, 1) |
