Stat card
A KPI tile for the top of a dashboard: a label, a large number, the change against an earlier period and a trend line. Use it when one figure needs its context beside it. For a bare figure, use the animated number; for a trend alone, use the sparkline.
Install
npx shadcn@latest add @thrum-pro/stat-cardThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Automatically installs icons arrow-down-right, arrow-up-right and minus from the icon set.
Data shape
readonly (number | null)[] // the trend prop: oldest first; null leaves a gap[41, 44, 43, null, 46, 52, 55]Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | Required | What the number is. Shown above it and used as the name of the card. |
value | number | Required | The number. Changing it rolls from the number on screen to the new one. |
format | Intl.NumberFormatOptions | Default compact | How the value is written. Plain data, so a server component can pass it. |
locale | string | Default "en-US" | Locale for the value and the change. |
delta | number | – | Change against the comparison period, as a fraction: 0.124 is +12.4%. Leave out to hide the chip. |
deltaLabel | string | – | What the change is compared with, for example “vs last week”. |
goodDirection | "up" | "down" | Default "up" | Which direction is good news. It decides the colour of the arrow, never its direction. |
trend | readonly (number | null)[] | – | Values for the trend line, oldest first. null leaves a gap. Leave out to hide the line. |
sound | boolean | Default true | Play a soft tone when the value lands, if the visitor has sound on. |
className | string | – | Sets the size. The card fills the width it is given. |
Motion and sound
Motion
- First draw: the trend line is revealed left to right in 700 ms. The value and the change appear at once.
- A new value rolls from the number on screen in about 400 ms with no overshoot. The change rolls with it, and the arrow turns at once.
- A new trend with the same number of points morphs in 400 ms.
- The card keeps its size while numbers roll: each number reserves the width of its final text.
- Reduced motion: everything appears complete and changes instantly.
Sound
- A short tone when the value lands after a change. The change chip is silent.
Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works
Accessibility
- The card is a group named by its label. Screen readers hear the label, the value, the signed change with its comparison, then the trend summary.
- Direction is an arrow and a sign: “+12.4%” with an arrow up, “-3.1%” with an arrow down, “0%” with a level dash. Colour only adds whether that is good news.
- The trend line is an image with a spoken summary: first, last, lowest and highest value.
- Nothing in the card takes focus: there is nothing to operate.
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/stat-card.tsx- Packages
motion- Brings along
- Chart foundationsMotion tokensAnimated numberSparkline
- Icons
arrow-down-rightarrow-up-rightminus
Changelog
- 1.0.0 · 2026-12-02First release.