Stat Cards

KPI cards with a big value, the delta written as a sentence, and a scrubbable sparkline or progress bar beside it — the row every dashboard opens with.

KPI row

@spectrumui/stat-cards

previous + progress — the budget pair

Manual installation

Prefer to copy by hand? Open the Code tab on any example above and switch to the file you need — every source file is there, not just the demo. Drop them in your project like this:

  • chart-engine.tsxcomponents/spectrumui/charts/chart-engine.tsx
  • stat-cards.tsxcomponents/spectrumui/charts/stat-cards.tsx

There is nothing to install — this chart draws its own SVG and imports only @/lib/utils.

Usage

import { StatCards } from '@/components/spectrumui/charts/stat-cards';

<StatCards cards={cards} columns={4} />
  • Set goodWhen: 'down' on metrics where falling is healthy, like churn — otherwise the delta turns red.
  • Pass previous to compare against last period instead of the first point in the series.
  • A card with progress renders a bar instead of a sparkline.

Props

PropTypeDefaultDescription
cardsStatCardData[]STAT_CARDSOne entry per tile. Each takes a label, a series or value, and optionally previous, progress, format, goodWhen and deltaLabel.
columns1 | 2 | 3 | 42Grid columns at the widest breakpoint. Always one column on mobile.
status'ready' | 'loading' | 'empty' | 'error''ready'Which state to render. All four reserve the same frame height, so nothing shifts when data lands.
onRetry() => void-Called by the retry button in the error state. Omit it and no button is shown.
classNamestring-Merged onto the root element.