Skip to content
InsightCharts

Search

Search guides and components

KPI grid

A responsive grid of trend cards drawn from one dataset: each metric shows its latest value, its change and a sparkline.

Use when
The top of a dashboard or a monthly report: three to eight metrics tracked over the same periods. Pass one table with a column per metric.
Avoid when
Figures without a series behind them (use stat row); comparing the metrics with each other on one scale (use line chart or small multiples); more than eight cards.

Preview

Monthly active users rose from 38,100 to 48,200 in 2024

Four product metrics by month, 2024. Change is measured against January.

Monthly active users
48.2K
+26.5%since Jan 2024
Recurring revenue
$589K
+43%since Jan 2024
Monthly churn
2.1%
−2.1 ptssince Jan 2024
Median first response
2.2 h
−46.3%since Jan 2024

Source: Internal analytics · Illustrative data

Composition

Built from

The pieces kpi grid renders or expects in its slots.

Molecules

1

A KPI card computed from a series: the latest value, its change against a baseline in the same data, and a sparkline of the series.

Atoms

2

A word-sized line or bar series without axes, with the latest point marked.

ThroughTrend card

A compact, bordered KPI tile: label, value, change against a baseline and an optional trend graphic.

ThroughTrend card

Used in

1 template uses kpi grid.

Templates

1

A recurring report. It has a masthead with the report name and period, a headline that states the main change, a KPI grid with changes and sparklines, a ranked list beside one or two trend charts, an optional comparison table, short notes and a source note.

Installation

$ pnpm dlx shadcn@latest add @insightcharts/kpi-grid

The CLI copies the source into your project and needs the @insightcharts registry in components.json; see installation. With the package, import it by name:

import { KpiGrid } from "insightcharts";

Examples

Two columns, change against the previous month

Monthly active users
48.2K
+2.1%vs Nov 2024
Recurring revenue
$589K
+4.1%vs Nov 2024

Six metrics

Monthly active users
48.2K
+26.5%since Jan 2024
Recurring revenue
$589K
+43%since Jan 2024
Monthly churn
2.1%
−2.1 ptssince Jan 2024
Median first response
2.2 h
−46.3%since Jan 2024
Net promoter score
46
+15since Jan 2024
Support tickets
1,158
−37.1%since Jan 2024

Illustrative data

Props

PropTypeDefaultDescription
dataDataInputOne dataset in time order: a row per period, a column per metric. Omit inside <InsightData>.
transformTransform | Transform[]Applied once, before the cards read the rows.
xstringPeriod field shared by every metric.
metricsrequired{ y, label, format?, upIsGood?, compare?, change?, deltaFormat?, deltaLabel?, context?, value?, delta?, kind? }[]One card per metric; each takes the props of trend-card.
compare"first" | "previous" | number"first"Baseline for every card's change; a metric can override it.
change"percent" | "absolute""percent"Relative change, or the difference between the two values; a metric can override it. An absolute change of a percentage metric is shown in percentage points ("−2.1 pts").
deltaFormatFormatSpecFormat for absolute changes, e.g. "{value} pp" or "signed"; a metric can override it. Default: points for percentage formats, otherwise the metric's own format.
columnsnumberPreferred columns. Default: up to four, reduced to fit cards of at least 200px.
titlestringThe main fact with its number, or a plain label.
subtitlestringPopulation and period.
sourcestringShown under the grid as "Source: ...".
notestringMethod note or caveat.
themeThemeInputTheme override, passed on to every card.
mode"auto" | "system" | "light" | "dark""auto"Colour mode.