Skip to content
Browse docs and components

Stat

stat

A metric card with the value, a coloured change against the last period and a sparkline drawn as plain SVG on the server. Says which direction is good, so falling latency reads green.

Responsive

Install

$npxshadcnadd@forme/stat

Adds the component, its registry dependencies, and the token stylesheet you import once.

API reference

Read from the source, so it is the API of the file you install. A prop marked * is required.

Stat

A metric: the number, its change, and the shape of how it got there.

PropTypeDefaultDescription
label*ReactNode—
value*ReactNode—Already formatted. The stat does not guess your currency or your locale.
deltanumber—Change against the previous period, as a fraction: 0.124 is +12.4%. Its sign picks the colour, unless invertDelta says that down is good (churn, latency).
invertDeltabooleanfalse
deltaLabelReactNode—Short context for the delta, such as "vs last week".
trendreadonly number[]—A series for the sparkline. Two points or more, any range.

Also takes every prop of <div> attributes.

Sparkline

A line with a flat tint under it, in the current text colour.

PropTypeDefaultDescription
points*readonly number[]—
classNamestring—