---
title: "Measurement"
description: "Shows a length, weight, speed, volume, or temperature in the units of the reader: metric, US, or UK. The metric value shows in a tooltip."
url: https://gelatinui.com/components/measurement
markdown_url: https://gelatinui.com/components/measurement.md
access: free
install: "npx shadcn@latest add @gelatin-ui/measurement"
registry_item: https://gelatinui.com/r/measurement.json
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Measurement

> Shows a length, weight, speed, volume, or temperature in the units of the reader: metric, US, or UK. The metric value shows in a tooltip.

Page: https://gelatinui.com/components/measurement

## When to use it

Best for: A metric value that each reader sees in their own units: metric, US, or UK.

- Store the value in the metric base unit of `kind`, and let the locale pick the units.
- Pass `unit` to show one fixed unit.
- Use `MeasurementEmpty` for a row with no value.

## When not to use it

- For a number with no unit system, use [Number Text](https://gelatinui.com/components/number-text.md).
- For a size in bytes, use [File Size](https://gelatinui.com/components/file-size.md).

## Notes for agents

- The value is metric: meters, square meters, kilograms, degrees Celsius, km/h, or liters.
- `system` is `auto` by default: en-US gets US units, en-GB gets UK units, other locales get metric.
- A converted value shows the metric text in a Tooltip and takes one tab stop. `tooltip={false}` turns it off.
- It has no size prop: set the size on the parent.

## Anatomy

```text
Measurement
└─ MeasurementEmpty (0..n)
```

## API reference

### Measurement

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `number \| null` |  | The value in the metric base unit of `kind`: meters (`distance`, `length`), square meters, kilograms (`mass`, `bodyWeight`), degrees Celsius, kilometers per hour, or liters. `null`, `undefined`, and `NaN` show the empty text. |
| `kind` | `MeasurementKind` |  | What the value measures: `distance`, `length`, `area`, `mass`, `bodyWeight`, `temperature`, `speed`, or `volume`. |
| `system` | `"auto" \| MeasurementSystem` | "auto" | The unit system: `auto` (default) reads it from the locale (US units for en-US, Liberia, and Myanmar; UK units for en-GB; else metric), or set `metric`, `us`, or `uk`. |
| `unit` | `string` |  | One unit in place of the ladder: an `Intl` unit of the kind (`"kilometer"`, `"foot"`, `"pound"`). The value converts to it, and `system` is not read. |
| `length` | `"long" \| "narrow" \| "short"` | "short" | The unit words: `short` (default, "5.2 km"), `long` ("5.2 kilometers"), or `narrow` ("5.2km"). |
| `tooltip` | `boolean` | true | A converted value shows the metric source in a Tooltip ("5.2 km" on "3.2 mi"), with a dotted underline and one tab stop. Default `true`. |
| `animated` | `boolean` | false | Rolls the digits on a change (the Rolling Number). Default `false`: the text swaps. |
| `locale` | `string` |  | The BCP 47 locale. Default: the `DisplayLocaleProvider` locale, else `"en-US"`. |
| `children` | `ReactNode` |  | A `MeasurementEmpty` part: the words of no value. With a value, they are not drawn. |

### MeasurementEmpty

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `data-slot` | `string` |  | The `data-slot` of the root: the item's own slot (`"time-ago"`). Default `"empty-value"`. |

Also takes every prop of Base UI `UseRender`: https://base-ui.com/react/components/use-render

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| Measurement | `measurement` |  |  |  |
| MeasurementEmpty | `measurement-empty` |  |  |  |

## Usage

Pass the metric value and its kind. Put a `MeasurementEmpty` inside for a run with no distance.

```tsx title="run-log.tsx"
import { Measurement, MeasurementEmpty } from "@/components/ui/measurement";

const RUNS: { day: string; meters: number | null }[] = [
  { day: "Monday", meters: 5200 },
  { day: "Wednesday", meters: 8400 },
  { day: "Friday", meters: null },
];

export function RunLog() {
  return (
    <ul className="flex w-56 flex-col gap-1 text-sm">
      {RUNS.map((run) => {
        return (
          <li key={run.day} className="flex justify-between">
            {run.day}
            <Measurement value={run.meters} kind="distance">
              <MeasurementEmpty>No GPS</MeasurementEmpty>
            </Measurement>
          </li>
        );
      })}
    </ul>
  );
}
```

## 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/measurement
```

It adds 37 registry items: 34 files, 6217 lines, and the npm packages `@base-ui/react`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Full Value](https://gelatinui.com/components/full-value.md)
- [Rolling Number](https://gelatinui.com/components/rolling-number.md)

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

- [Number Text](https://gelatinui.com/components/number-text.md)
- [File Size](https://gelatinui.com/components/file-size.md)
- [Duration](https://gelatinui.com/components/duration.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Tab | Moves to a converted value and shows the metric value in a Tooltip. |

## Accessibility

It renders a `data` element, and its `value` attribute keeps the metric number.

The unit words come from `Intl.NumberFormat`, so a screen reader reads them in the page language.

## Motion

| Part | Motion |
| --- | --- |
| Value | none · with `animated`, the digits roll on a change |
