

<InteractiveDemo
  name="qr-code"
  controls="[
  {
    type: 'string',
    name: 'value',
    defaultValue: 'https://dotui.org',
  },
  {
    type: 'enum',
    name: 'errorCorrection',
    options: ['L', 'M', 'Q', 'H'],
    defaultValue: 'M',
  },
]"
/>

## Installation [#installation]

<CodeBlockTabs defaultValue="npm">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="npm">
      npm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="pnpm">
      pnpm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="yarn">
      yarn
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="bun">
      bun
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="npm">
    ```bash
    npx shadcn@latest add @dotui/qr-code
    ```
  </CodeBlockTab>

  <CodeBlockTab value="pnpm">
    ```bash
    pnpm dlx shadcn@latest add @dotui/qr-code
    ```
  </CodeBlockTab>

  <CodeBlockTab value="yarn">
    ```bash
    yarn dlx shadcn@latest add @dotui/qr-code
    ```
  </CodeBlockTab>

  <CodeBlockTab value="bun">
    ```bash
    bun x shadcn@latest add @dotui/qr-code
    ```
  </CodeBlockTab>
</CodeBlockTabs>

## Usage [#usage]

```tsx
import { QRCode } from '@/components/ui/qr-code'
;<QRCode value="https://dotui.org" aria-label="dotUI website" />
```

Pass an `aria-label` describing the destination — to a screen reader, an unlabeled QR code is meaningless.

## Logo [#logo]

Pass children to display a logo at the center of the code. The modules behind it are excavated so it sits in clean whitespace, and the default error correction level is raised to `H` to compensate for the covered area.

```tsx
<QRCode value="https://dotui.org" aria-label="dotUI website">
  <Logo />
</QRCode>
```

## Error correction [#error-correction]

QR codes embed redundancy so they scan even when partially obscured. The `errorCorrection` prop sets the level: `L` (7%), `M` (15%), `Q` (25%) or `H` (30%) — higher levels produce a denser code.

The code renders with the theme's foreground on the theme's background. Scanners expect dark modules on a light background; in dark themes the code is inverted, which some scanners reject. Always test scanning with your real theme, colors and logo.

## Examples [#examples]

<Examples className="sm:grid-cols-2">
  <Example name="qr-code/demos/basic" title="Basic" />

  <Example name="qr-code/demos/with-logo" title="With Logo" />

  <Example name="qr-code/demos/sizes" title="Sizes" />
</Examples>

## API Reference [#api-reference]

<Reference name="qr-code" />
