Skip to content
InsightCharts

Search

Search guides and components

Trend card

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.

Use when
A metric whose recent history matters as much as its level: users, revenue, response time. Pass the series and field names; the figure, the change and the sparkline all come from the same rows, so they cannot disagree.
Avoid when
A number with no history (use big number or stat tile); several metrics from one dataset (use kpi grid); a series the reader must read values from (use line chart).

Preview

Monthly active users
48.2K
+26.5%since Jan 2024

Composition

Built from

The pieces trend card renders or expects in its slots.

Atoms

2

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

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

Used in

1 molecule and 1 template use trend card.

Molecules

1

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

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.

ThroughKPI grid

Installation

$ pnpm dlx shadcn@latest add @insightcharts/trend-card

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 { TrendCard } from "insightcharts";

Examples

Down is good, trend on the right

Median first-response time
2.2 h
−46.3%since Jan 2024

Absolute change against the previous period, bars

Unemployment rate
4.3%
+0.2 ptsvs Nov 2024
Highest month of 2024

Props

PropTypeDefaultDescription
labelrequiredstringWhat the figure measures, sentence case.
dataDataInputRows in time order, one per period. Omit inside <InsightData>.
transformTransform | Transform[]Applied to the rows before anything is computed.
yrequiredstringValue field: the series drawn and the source of the figure and its change.
xstringPeriod field, used to name the baseline and in the sparkline tooltip.
valuenumber | stringThe figure shown. Default: the last row's y.
deltanumber | stringThe change shown. Default: computed from the series according to compare.
compare"first" | "previous" | number"first"Baseline for the computed change: first row, previous row, or a number of rows back (12 for year-on-year in monthly data).
change"percent" | "absolute""percent"Relative change, or the difference between the two values (use for rates and shares). An absolute change of a percentage is shown in percentage points.
deltaFormatFormatSpecFormat for a computed absolute change, e.g. "{value} pp" or "signed". Default: points ("+1.9 pts") when format is a percentage, otherwise format.
deltaLabelstringWhat the change is against. Default: "since {first period}" when x is given.
upIsGoodbooleantrueWhether an increase is good news; decides the delta colour.
contextstringA line under the figure that gives it meaning.
formatFormatSpec"auto"Number format for the figure and the sparkline tooltip.
kind"line" | "bar""line"Sparkline form: a line for a trend, bars for discrete counts.
areabooleanfalseLight fill under the line; the scale then includes zero.
trendPosition"bottom" | "right""bottom"Where the sparkline sits; right falls back to bottom in narrow cards.
themeThemeInputTheme override, passed on to the tile and sparkline.
mode"auto" | "system" | "light" | "dark""auto"Colour mode.