A card for a total made of parts over time: a headline with its change, a period menu, a soft-gradient area chart and a legend with each part's total. Point at a part and the headline becomes its total.
On this page
Used for
- Runs, spend or tokens split by agent, model or team over a week, a month or a year
- A dashboard card whose total is made of parts
- The share each part holds over time, in percent mode
Examples
Curve
Overlap
Percent
Installation
npx knowns-ui@latest add area-trend-cardFor Claude Code, Cursor or Codex: installs it and wires the props to your own data.
Paste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install prompt
Install Area trend card from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/area-trend-card
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add area-trend-card
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/animated-number.tsx
- components/ui/knowns/chart/chart.tsx
- components/ui/knowns/chart/chart-utils.ts
- components/ui/knowns/chart/sparkline.tsx
- components/ui/knowns/chart/chart-radial.tsx
- components/ui/knowns/use-floating.ts
- components/ui/knowns/tooltip.tsx
- components/ui/knowns/tooltip-utils.ts
- components/ui/knowns/avatar.tsx
- components/ui/knowns/badge.tsx
- components/ui/knowns/spinner.tsx
- components/ui/knowns/button.tsx
- components/ui/knowns/menu.tsx
- components/ui/knowns/dropdown.tsx
- components/ui/knowns/blocks/analytics/area-trend-card.tsx
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0, class-variance-authority@^0.7.1.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/area-trend-card, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "area-trend-card" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.Props
- title / icon
string / ReactNode- Default
required / - - The label above the headline and an optional 16px mark before it.
- data / x / seriesrequired
ChartDatum[] / string / ChartSeries[]- One row per point on the x axis, the key of its label, and the parts.
- mode
"stacked"|"overlap"|"percent"- Default
"stacked" - Add the parts up, draw each from the baseline, or show each one's share of the whole.
- curve
"smooth"|"linear"- Default
"smooth" - A monotone curve that never dips below the baseline, or straight segments.
- periods / period / defaultPeriod / onPeriodChange
AreaTrendPeriod[] / string- The dropdown. The card does not own the data: swap `data` when a period is picked.
- delta / goodWhen
number / "up"|"down"- Default
- / "up" - The change as a fraction (0.082 is +8.2%) and which way is good news.
- unit / format / headlineFormat / formatX
string / functions- Default
compact - The thing counted, and how values and categories read.
- height / chartLabel
number / string- Default
200 / title - Plot height and the chart's name for assistive tech.
- Motion
280 ms in-out- A period change tweens the areas and rolls the headline. Hover dims by opacity in 120 ms. Nothing plays on first render or with reduced motion.
| Prop | Type | Default | Description |
|---|---|---|---|
| title / icon | string / ReactNode | required / - | The label above the headline and an optional 16px mark before it. |
| data / x / seriesrequired | ChartDatum[] / string / ChartSeries[] | required | One row per point on the x axis, the key of its label, and the parts. |
| mode | "stacked" | "overlap" | "percent" | "stacked" | Add the parts up, draw each from the baseline, or show each one's share of the whole. |
| curve | "smooth" | "linear" | "smooth" | A monotone curve that never dips below the baseline, or straight segments. |
| periods / period / defaultPeriod / onPeriodChange | AreaTrendPeriod[] / string | - | The dropdown. The card does not own the data: swap `data` when a period is picked. |
| delta / goodWhen | number / "up" | "down" | - / "up" | The change as a fraction (0.082 is +8.2%) and which way is good news. |
| unit / format / headlineFormat / formatX | string / functions | compact | The thing counted, and how values and categories read. |
| height / chartLabel | number / string | 200 / title | Plot height and the chart's name for assistive tech. |
| Motion | 280 ms in-out | - | A period change tweens the areas and rolls the headline. Hover dims by opacity in 120 ms. Nothing plays on first render or with reduced motion. |
What it handles
- 01Shows a headline total with its change, and swaps the headline to a series' total when you point at its band or line, or at its entry in the legend, with the digits rolling.
- 02Draws the parts stacked, overlaid, or as each one's share of the whole, with a soft gradient under each line.
- 03Takes its data from you: a period pick calls onPeriodChange and you pass the new rows; the chart tweens to them.
- 04Turns the change green when it moves the good way, with goodWhen="down" for cost and errors.
- 05Reads out the headline and the focused series to a screen reader, and keeps the chart's own keyboard tooltip and data table.
States
- Point at a band, a line or a legend entry
- The other series dim, the headline rolls to that series' total, the change hides
- 120ms dim, 280ms roll
- Period change
- The areas tween to the new rows and the headline rolls to the new total
- 280ms, ease in-out
- First render
- Nothing plays
- none
- Reduced motion
- Every change lands at once
- 0ms
| State | What moves | Timing |
|---|---|---|
| Point at a band, a line or a legend entry | The other series dim, the headline rolls to that series' total, the change hides | 120ms dim, 280ms roll |
| Period change | The areas tween to the new rows and the headline rolls to the new total | 280ms, ease in-out |
| First render | Nothing plays | none |
| Reduced motion | Every change lands at once | 0ms |
Works with
When to use
When to use
- A dashboard card for a total made of parts over time: runs by agent, spend by model, tokens by team.
- The share each part holds over a week, a month or a year, with the headline following the part you point at.
When not to use
- A bare chart with no headline or period menu: use Chart.
- Status day by day for one service: use Uptime Bar.
- A total and where it happens on two axes: use Heatmap Card.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Area Trend Card to my app and wire it to my own data.
- I need a dashboard card for a total made of parts over time: runs by agent, spend by model, tokens by team. Set that up with the Knowns UI Area Trend Card.
- Which Area Trend Card props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "area-trend-card" }) and search_docs({ query: "area trend card" }).