---
title: "EAN-13 Barcode"
description: "The barcode on a retail pack that a till scanner reads. It shows the 13 digits under the bars and can add a 2- or 5-digit add-on."
url: https://gelatinui.com/components/ean-13-barcode
markdown_url: https://gelatinui.com/components/ean-13-barcode.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/ean-13-barcode"
version: "2026-11-11"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# EAN-13 Barcode

> The barcode on a retail pack that a till scanner reads. It shows the 13 digits under the bars and can add a 2- or 5-digit add-on.

Page: https://gelatinui.com/components/ean-13-barcode

## When to use it

Best for: A retail pack code that a till scanner reads, on screen or on a printed label.

- Pass 12 digits and the check digit is added, or 13 digits to check the last one.
- Use `addOn` for the 2-digit issue number of a magazine or a 5-digit price.
- Use `unit="mm"` with `moduleWidth={0.33}` for a print at 100%.
- Use `onError` to turn a field invalid on a wrong digit.

## When not to use it

- For a small pack where 13 digits do not fit, use an [EAN-8 Barcode](https://gelatinui.com/components/ean-8-barcode.md).
- For a book, use an [ISBN Barcode](https://gelatinui.com/components/isbn-barcode.md).
- When the kind of code is known only at run time, use a [Barcode](https://gelatinui.com/components/barcode.md).
- For a link that a phone opens, use a [QR Code](https://gelatinui.com/components/qr-code.md).

## Notes for agents

- `fit` fills the width of the parent, in whole px a module when that loses one module or less.
- Spaces and hyphens in `value` are allowed; the text under the bars shows the 13 digits only.
- A wrong check digit, a letter, or a wrong digit count shows a help line, not bars, and calls `onError`.
- The plate is white in both themes, so the code scans in dark mode. `plate={false}` drops it on your own white paper.
- `status` sets loading and empty. `labels` changes the words of the empty and error boxes.
- The digits never mirror in right to left.

## Anatomy

```text
Ean13Barcode
```

## API reference

### Ean13Barcode

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `aria-label` | `string` |  | Defines a string value that labels the current element. The accessible name. Default "<kind>: <text>" ("EAN-13: 5901234123457"); Code 128 and Code 39 say the kind only, or the link, as their value can be a return code or a key. |
| `fit` | `boolean` |  | Fill the width of the parent, in whole px a module when that loses one module of width or less (as the QR Code), else the exact width. Default false: the narrowest bar sets the size (`moduleWidth`, `height`, `unit`). |
| `moduleWidth` | `number` |  | The narrowest bar in `unit`. Default 2 (px). Use whole px on screen. Values under 0.5px or 0.1mm (and 0, or not a number) clamp to them: the layout divides by this width. |
| `height` | `number` |  | The bar height in `unit`. Default 64 (px). With `fit`, the height in px. |
| `textPosition` | `"bottom" \| "none"` |  | The human-readable text under the bars. Default `bottom`. |
| `unit` | `"mm" \| "px"` |  | `mm` sizes the code for print: `moduleWidth={0.33}` is EAN-13 at 100%. Default `px`. |
| `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 (a wrong check digit, a letter in EAN-13), 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. |
| `value` | `string` |  | The data etiket encodes. 12 or 13 digits (spaces and hyphens allowed): a missing check digit is added. |
| `addOn` | `string` |  | A 2-digit (EAN-2) or 5-digit (EAN-5) add-on after the main code: an issue number or a price. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| Ean13Barcode | `ean-13-barcode` |  |  |  |

## Usage

Pass the 12 or 13 digits of the pack.

```tsx title="pack-barcode.tsx"
import { Ean13Barcode } from "@/components/pro/labels/ean-13-barcode";

export function PackBarcode() {
  return <Ean13Barcode value="5901234123457" />;
}
```

## 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/ean-13-barcode
```

It adds 17 registry items: 16 files, 2320 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

- [Barcode](https://gelatinui.com/components/barcode.md)
- [QR Code](https://gelatinui.com/components/qr-code.md)
- [Price](https://gelatinui.com/components/price.md)
- [Till Receipt](https://gelatinui.com/components/till-receipt.md)
- [EAN-8 Barcode](https://gelatinui.com/components/ean-8-barcode.md)
- [UPC-A Barcode](https://gelatinui.com/components/upc-a-barcode.md)

## Accessibility

It is an image named "EAN-13: <digits>" by default. Pass `aria-label` to say what the code is for.

The digits also show as text under the bars, unless `textPosition="none"`.
