---
title: "Aztec Code"
description: "A square code for a train ticket or an event pass on a phone. A gate reads it from a dim screen, and it needs no white margin."
url: https://gelatinui.com/components/aztec-code
markdown_url: https://gelatinui.com/components/aztec-code.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/aztec-code"
version: "2026-11-11"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Aztec Code

> A square code for a train ticket or an event pass on a phone. A gate reads it from a dim screen, and it needs no white margin.

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

## When to use it

Best for: A ticket or a pass on a phone screen that a gate or a guard scans.

- Use it for the ticket data of a train, a bus, or an event.
- Use `pixelSize` for the outer width; the code is never wider.
- Use `plate={false}` when the code sits on your own white paper.

## When not to use it

- For a link that any phone camera opens, use a [QR Code](https://gelatinui.com/components/qr-code.md).
- For a printed boarding pass or an ID card, use a [PDF417 Code](https://gelatinui.com/components/pdf417-code.md).
- For a small tag or part mark, use a [Data Matrix Code](https://gelatinui.com/components/data-matrix-code.md).

## Notes for agents

- `fit` fills the width of the parent, in whole px a module when that loses one module or less.
- The bullseye in the middle needs no quiet zone. The plate keeps 1 module, so its round corner never cuts a module.
- The default size is 160px. Modules are whole px when that loses at most one module.
- Too much data (about 2,500 characters of text) shows a help line, not a code, and calls `onError`.
- The plate is white in both themes, so the code scans in dark mode.
- `status` sets loading and empty. `labels` changes the words of the empty and error boxes.
- The code never mirrors right to left.

## Anatomy

```text
AztecCode
```

## API reference

### AztecCode

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `aria-label` | `string` |  | Defines a string value that labels the current element. The accessible name. Default the kind ("Data Matrix code"), or "<kind>: <value>" for a link. |
| `value` | `string` |  | The data etiket encodes. The data of the ticket. Default size 160px. |
| `pixelSize` | `number` |  | The outer width in px, quiet zone included. The height follows the symbol. |
| `fit` | `boolean` |  | Fill the width of the parent, in whole px a module when that loses one module or less (the QR Code rule), else the exact width. Default false. Wide codes (postal, PDF417) on a phone. |
| `plate` | `boolean` |  | The light plate under the code. Default true. |
| `status` | `DataStatus` |  | 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. |
| `labels` | `Partial<CodeSymbolLabels>` |  | The texts of the empty and error states. |
| `onError` | `function` |  | Runs once for each new error (too much data, a character the kind cannot hold), after commit. It does not run again for the same error, and typed values are deferred: a field that shows the error should derive it from the value with the kind's encoder (cached, so free), not clear it on each change. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| AztecCode | `aztec-code` |  |  |  |

## Usage

Pass the ticket data.

```tsx title="ticket-code.tsx"
import { AztecCode } from "@/components/pro/labels/aztec-code";

export function TicketCode() {
  return <AztecCode value="NW 2611 LJU-FRA 14C" aria-label="Ticket code: Mila Novak" />;
}
```

## 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-pro/aztec-code
```

It adds 17 registry items: 16 files, 2062 lines, and the npm packages `@mantine/hooks`, `clsx`, `etiket`, `tailwind-merge`, `tailwind-variants`.

## 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

- [QR Code](https://gelatinui.com/components/qr-code.md)
- [PDF417 Code](https://gelatinui.com/components/pdf417-code.md)
- [Data Matrix Code](https://gelatinui.com/components/data-matrix-code.md)

## Accessibility

It is an image named "Aztec code" by default, or "Aztec code: <link>" for a link. Pass `aria-label` to say whose ticket it is.

Show the route, the seat, and the name as text next to the code.
