---
title: "GS1 Data Matrix Code"
description: "A small square code on a medicine pack or a medical device. It holds the product number, lot, expiry date, and serial, and checks each one."
url: https://gelatinui.com/components/gs1-data-matrix-code
markdown_url: https://gelatinui.com/components/gs1-data-matrix-code.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/gs1-data-matrix-code"
version: "2026-11-11"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# GS1 Data Matrix Code

> A small square code on a medicine pack or a medical device. It holds the product number, lot, expiry date, and serial, and checks each one.

Page: https://gelatinui.com/components/gs1-data-matrix-code

## When to use it

Best for: The product number, expiry, lot, and serial in one small square, for medicine, devices, and fresh food.

- Pass the element string with each AI in brackets: "(01)09506000134352(17)270430(10)LOT42".
- Put the fixed-length fields, (01) and the dates, before the lot (10) and the serial (21).
- Use `onError` to stop a pack whose GTIN or date is wrong.

## When not to use it

- For an ID that is not GS1 data, use a [Data Matrix Code](https://gelatinui.com/components/data-matrix-code.md).
- For a link that any phone camera opens, use a [QR Code](https://gelatinui.com/components/qr-code.md).
- For a 1D code on a case or a pallet, use a [Barcode](https://gelatinui.com/components/barcode.md).

## Notes for agents

- `fit` fills the width of the parent, in whole px a module when that loses one module or less.
- The GTIN check digit of (01), (02), and (00), the YYMMDD dates of (11) to (17), and the 6 digits of a measure are checked first. A wrong field is an error, not a code.
- Plain text with no AI in brackets is an error.
- The default name is always "GS1 Data Matrix code". Pass `aria-label` with the product.
- Show the fields as text next to the code, as the pack rules ask.
- `pixelSize` is the outer width, the quiet zone of 1 module included. The default size is 160px.
- `status` sets loading and empty. `labels` changes the words of the empty and error boxes.

## Anatomy

```text
Gs1DataMatrixCode
```

## API reference

### Gs1DataMatrixCode

| 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. GS1 element strings: "(01)" and the GTIN-14, then "(17)" expiry, "(10)" lot, "(21)" serial. |
| `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 |
| --- | --- | --- | --- | --- |
| Gs1DataMatrixCode | `gs1-data-matrix-code` |  |  |  |

## Usage

Pass the GS1 element string of the pack.

```tsx title="pack-code.tsx"
import { Gs1DataMatrixCode } from "@/components/pro/labels/gs1-data-matrix-code";

export function PackCode() {
  return (
    <Gs1DataMatrixCode
      value="(01)09506000134352(17)270430(10)LOT42(21)SN7731"
      aria-label="Pack code, lot LOT42"
    />
  );
}
```

## 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/gs1-data-matrix-code
```

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

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

## Accessibility

It is an image named "GS1 Data Matrix code" by default. Pass `aria-label` to say which product it is.

Show the GTIN, lot, expiry, and serial as text next to the code too.
