Skip to content

Molecules · Stat

Stat

One number that matters, and how it has moved. The number is the star of the show. The label is small, set in a monospaced font and kept quiet.

Best for
One headline number and how it has moved. Up to four in a row.
Not for
A value that only makes sense as a chart: use ChartPanel.

This page as Markdown, a plain-text copy for a coding agent (an AI tool that writes code).

Examples

A row of stats

Kits dispatched
18

up 12% from last week, an improvement

Failed syncs
3

down 40% from last week, an improvement

Depots offline
2

up 1 from last week, a decline

Payload
24kg
Code
tsx
<div className="grid grid-cols-2 sm:grid-cols-4 gap-6 w-full">  <Stat    label="Kits dispatched"    value={18}    padTo={3}    delta={{ value: '12%', direction: 'up', sentiment: 'positive', period: 'last week' }}  />  <Stat    label="Failed syncs"    value={3}    delta={{ value: '40%', direction: 'down', sentiment: 'positive', period: 'last week' }}  />  <Stat    label="Depots offline"    value={2}    delta={{ value: '1', direction: 'up', sentiment: 'negative', period: 'last week' }}  />  <Stat label="Payload" value={24} unit="kg" /></div>

Without a delta

Kits dispatched
18
Code
tsx
<div className="max-w-[10rem] w-full">  <Stat label="Kits dispatched" value={18} padTo={3} /></div>

KPI tiles: compact, with one accent tile for the figure to act on

Open orders
42
Shipped today
128
Returns
3
Stock value
€18.4k
Code
tsx
<div className="grid grid-cols-2 sm:grid-cols-4 gap-3 w-full">  <Stat variant="kpi" accent label="Open orders" value={42} />  <Stat variant="kpi" label="Shipped today" value={128} />  <Stat variant="kpi" label="Returns" value={3} />  <Stat variant="kpi" label="Stock value" value="€18.4k" /></div>

Anatomy

PartWhat it is
LabelA dt (the "term" element of an HTML description list), in text.secondary.
ValueA dd (the matching "description" element) at 36px (pixels), set in Oxanium with tabular figures, so every digit is the same width.
PadOptional leading zeros in numeral.pad. They're aria-hidden, so screen readers skip them, and they only appear when the width is real.
UnitA short suffix beside the value, for example kg.
DeltaThe change. An arrow shows the direction, colour shows whether it's good or bad, and a spoken sentence says both for screen reader users.

Props

labelstring
The stat's name, for example "Kits dispatched".
valuenumber | string
Whole numbers get padded. Anything else (for example "4.2k") is shown exactly as given.
unitstring
Shown beside the value, for example "kg".
padTonumber
Pads a whole-number value to this many digits with dimmed zeros that screen readers skip (aria-hidden).
delta{ value: string; direction: 'up' | 'down'; sentiment: 'positive' | 'negative' | 'neutral'; period: string }
value comes already formatted (for example "12%"). direction picks the arrow. sentiment picks the colour, and it doesn't depend on direction: fewer failed syncs is down, and that's positive. period is what the number is compared with, for example "last week". It's both shown and spoken.
variant'default' | 'kpi'Default 'default'
default is the display-size hero numeral. kpi is a compact tile: a small uppercase label over a 24px value in the data font, for a row of four to six figures.
accentbooleanDefault false
kpi only: a solid signal-fill tile with its text in accent.signal.ink, for the one figure to act on. At most one per row.
classNamestring
Merged with the root classes. If two Tailwind utilities clash, the later one wins.
refRef<HTMLDivElement>
Passed through to the root div.
...restHTMLAttributes<HTMLDivElement>
Any standard div attribute, applied to the root div.

Keyboard

You can't reach this component with the keyboard. It has no keyboard behaviour of its own.

Do and don't

Do

  • Lay several Stats out in a plain div grid. Each one renders its own dl (description list), so you don't need a list element around them.
  • Set sentiment by what the change means, not by its direction: fewer failed syncs is down, and that's positive.
  • Say what the delta is compared with.
  • Only pad when every value in a row has the same fixed width.

Don't

  • Don't pad a value whose width isn't fixed. The zeros would be made up.
  • Don't put more than four stats in a row.
  • Don't use a Stat for a value that only makes sense as a chart.