Skip to content
Thrum

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-card

This 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

Type
readonly (number | null)[] // the trend prop: oldest first; null leaves a gap
Sample
[41, 44, 43, null, 46, 52, 55]

Props

PropTypeDefaultDescription
labelstringRequiredWhat the number is. Shown above it and used as the name of the card.
valuenumberRequiredThe number. Changing it rolls from the number on screen to the new one.
formatIntl.NumberFormatOptionsDefault compactHow the value is written. Plain data, so a server component can pass it.
localestringDefault "en-US"Locale for the value and the change.
deltanumber–Change against the comparison period, as a fraction: 0.124 is +12.4%. Leave out to hide the chip.
deltaLabelstring–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.
trendreadonly (number | null)[]–Values for the trend line, oldest first. null leaves a gap. Leave out to hide the line.
soundbooleanDefault truePlay a soft tone when the value lands, if the visitor has sound on.
classNamestring–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

SourcePro

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. 1.0.0 · 2026-12-02First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor