Stat
Display a key metric with a label, formatted value, trend and countdown
Source
LLM docs
Docs
Package
Usage
Stat displays a single key metric: a label, a formatted value and an optional trend
indicator. Use it to build dashboard stat rows, KPI cards and summary blocks.
Value formatting
Numeric values are formatted with NumberFormatter, Stat supports
the same separator and decimal scale props. Use prefix and suffix to render units,
currency or icons before and after the value:
Numeric strings ('1234.5') are formatted the same way as numbers. Other strings
('12k', 'N/A') are rendered as is.
To fully control value rendering, pass a formatter function. It receives the raw value
and returns any React node. Formatting props and animate are ignored when formatter is set:
Trend indicator
Set diff prop to display a trend delta below the value. Positive values are green with
an up arrow, negative values are red with a down arrow, zero is dimmed. By default,
the delta is rounded to at most one decimal and formatted as a signed percentage (+0.3%, -12%):
Use diffFormatter to customize the delta text and withDiffIcon={false} to hide the arrow:
Values and deltas are never truncated. In narrow containers, use responsive columns
(for example, SimpleGrid with cols={{ base: 1, sm: 3 }}) instead of a fixed number of columns.
Icon
Use icon prop to display an icon next to the value:
Loading state
Set loading prop to display a Skeleton in place of the value.
The trend indicator is hidden while loading is set:
Animated value
Set the animate prop to animate value changes with RollingNumber.
Animation only applies to numeric values:
Countdown
Stat.Countdown displays a live countdown to a target time. value is a Date
or a timestamp in milliseconds. Keep it stable between renders (create it with useState
or useMemo), a new value restarts the countdown.
format prop accepts dayjs-style tokens (D, H, m, s, S):
- Units absent from the format roll into the leading token:
mm:ssdisplays 62 minutes as62:00 Sdisplays tenths of a second,SShundredths andSSSmilliseconds- Literal characters are escaped with square brackets, for example
D[d] HH:mm:ss - The remaining time is rounded up: a 3 hour countdown starts at
03:00:00and00:00:00is displayed only when it has finished
Stat.Countdown supports the same display props and Styles API selectors as Stat:
onFinish is called once when the target time is reached, and onTick is called on every
tick with the remaining time in milliseconds.
Size
size prop scales the label, value, diff and icon. Change size in the configurator
above to see how it scales.
Color
Set the color prop to change the value color. It accepts a value from theme.colors or any
valid CSS color:
Compound components
For full control over the layout, use compound components instead of the shorthand props:
Stat.Icon– icon wrapper, always placed next to the value. Other components are rendered in the order they are declared.Stat.Label– caption displayed above the valueStat.Value– value wrapper, acceptsprefixandsuffixpropsStat.Diff– trend delta, acceptsvalue,formatter,withIconandlabelsprops (or custom children)
Example: dashboard stat row
Compose multiple Stat components in a SimpleGrid or
Group to build a stat row:
Accessibility
Stat.Countdownvalue is not announced on every tick. To announce milestones (for example "5 minutes left"), render your own live region and update it fromonTick.- When
loadingis set, the root element hasaria-busy="true". Stat.Diffrenders a visually hidden direction text after the delta ("increase", "decrease" or "no change"), screen readers announce+12.4% increase. UsediffLabelsonStatorlabelsonStat.Diffto translate these texts:
Styles API
Stat supports the Styles API; you can add styles to any inner element of the component with the classNames prop. Follow the Styles API documentation to learn more.
Component Styles API
Hover over selectors to highlight corresponding elements