---
title: "Mailmark Code"
description: "The 2D postage mark on a franked UK letter or parcel. It turns the Mailmark data that Royal Mail gives you into a square code."
url: https://gelatinui.com/components/mailmark-code
markdown_url: https://gelatinui.com/components/mailmark-code.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/mailmark-code"
version: "2026-11-11"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Mailmark Code

> The 2D postage mark on a franked UK letter or parcel. It turns the Mailmark data that Royal Mail gives you into a square code.

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

## When to use it

Best for: The postage mark of a franked UK letter or parcel, from the Mailmark data Royal Mail gives the sender.

- Pass `JGB ` and the fields, in uppercase A–Z, 0–9, and space.
- Use `pixelSize` 78, 104, or 130 for whole px modules (26 modules with the quiet zone).
- Use `plate={false}` on a white envelope or label.

## When not to use it

- For a tracking number that a hand scanner reads, use a 1D [Barcode](https://gelatinui.com/components/barcode.md).
- For the order facts on a packing slip, use a [Data List](https://gelatinui.com/components/data-list.md).

## Notes for agents

- `fit` fills the width of the parent, in whole px a module when that loses one module or less.
- The value must start with `JGB `. Lowercase letters and other characters are an error: make the value uppercase first.
- The code pads the value with spaces to 45 characters. About 50 characters is the most it holds.
- It checks only the characters and the length, not the meaning of each field.
- An error shows a help line, not a code. `onError` gets the error.

## Anatomy

```text
MailmarkCode
```

## API reference

### MailmarkCode

| 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 Mailmark data: "JGB " and the fields (A–Z, 0–9, space). Default size 128px. |
| `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 |
| --- | --- | --- | --- | --- |
| MailmarkCode | `mailmark-code` |  |  |  |

## Usage

Pass the Mailmark data, starting with `JGB `.

```tsx title="postage-mark.tsx"
import { MailmarkCode } from "@/components/pro/labels/mailmark-code";

export function PostageMark() {
  return <MailmarkCode value="JGB 012100123412345678AB19XY1A 0" pixelSize={78} />;
}
```

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

It adds 17 registry items: 16 files, 2061 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)
- [Data List](https://gelatinui.com/components/data-list.md)
- [Frame](https://gelatinui.com/components/frame.md)

## Accessibility

It is an image named "Mailmark code" by default. Pass `aria-label` to say what it is, for example "Mailmark code, 2nd Class".

Print the class as text next to the code, so people can read it too.
