Skip to content

Measurement

Free

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.

  • React 19
  • Tailwind CSS 4

Added Nov 9, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

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

run-log.tsx

Measurement

<data>
PropTypeDefaultDescription
valueRequirednumber | 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.
kindRequired"area""bodyWeight""distance""length""mass""speed""temperature""volume"—What the value measures: distance, length, area, mass, bodyWeight, temperature, speed, or volume.
system"auto""metric""uk""us""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.
unitstring—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").
tooltipbooleantrueA 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.
animatedbooleanfalseRolls the digits on a change (the Rolling Number). Default false: the text swaps.
localestring—The BCP 47 locale. Default: the DisplayLocaleProvider locale, else "en-US".
childrenReactNode—A MeasurementEmpty part: the words of no value. With a value, they are not drawn.
...props<data> attributes—Every other attribute goes to the <data>, with a ref.

MeasurementEmpty

<div>
PropTypeDefaultDescription
data-slotstring—The data-slot of the root: the item's own slot ("time-ago"). Default "empty-value".
From Base UIUseRenderBase UI docs
render—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.
  • 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.
TabMoves to a converted value and shows the metric value in a Tooltip.

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.

Value
none · with `animated`, the digits roll on a change

Built with

Installs with Measurement

  1. AddedMeasurement, with Full Value, Rolling Number.
Open the release