Skip to content
English

How it works

The line chart card with a filled gradient under each line that is not muted. The area is its own SVG path closed to the baseline; on entry it scales up from the bottom (transform only) while the line above it draws with dashoffset. With a muted comparison series the gradient stays on the lead line only, so the comparison never competes. New data morphs both paths through the CSS d property where supported.

Use it for

  • A running total or balance where the filled area helps read volume: savings, storage used, subscribers.
  • This year against last year, with last year as a quiet dotted line.
  • A dashboard tile where one card should feel calmer and heavier than a bare line.

Look elsewhere when

  • More than two series: overlapping areas turn muddy; use the line chart.
  • Values that go negative or swing around zero: areas imply a quantity from the baseline.
  • Parts of a whole over time: use stacked bars.

Usage

import { AreaChart } from './AreaChart.jsx'

const months = ['Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov']

export function SavingsCard() {
  return (
    <AreaChart
      title="Savings"
      subtitle="last 6 months"
      onOpen={() => {}}
      caption={(month) => `Balance in ${month}`}
      delta={{ value: 1240, label: 'vs last year' }}
      categories={months}
      series={[
        { name: 'This year', data: [13200, 14050, 14900, 15880, 17150, 18420] },
        { name: 'Last year', data: [10900, 11400, 12010, 12650, 13240, 13860], muted: true },
      ]}
      formatValue={(n) => '$' + n.toLocaleString('en-US')}
      color={3}
    />
  )
}

Props

PropTypeDefaultWhat it does
categoriesstring[]—X-axis categories, usually dates or week numbers. One column and one point per label. `labels` is the older name of this prop and still works (deprecated: in blocks `labels` means text overrides).
series{ name: string, data: (number | null)[], color?: number | string, muted?: boolean }[]—Up to 2 lines. The first one that is not muted leads: it sets the hero, the band and the tooltip colour. muted draws a dotted grey comparison line (last year, a plan) with no points and no area. color is 1–8 for --ds-chart-N or any CSS colour; null breaks the line.
title / subtitle / iconReactNode—Card header: a tinted icon tile, a 15px title and a quieter subtitle after it.
onOpen / action() => void / ReactNode—onOpen adds a chevron button at the end of the header. action replaces it with any node, such as a menu.
captionstring | (category: string, index: number) => string—Small line above the hero. A function receives the selected column, so the caption follows the selection.
valuenumber | string—Hero value. If omitted it is the lead series at the selected column. Numbers count from the old value to the new one.
unitstring—Unit after the hero and inside the tooltip, such as kg or %.
delta{ value: number, label?: string, positive?: 'up' | 'down', format?: (n) => string }—Change badge after the hero. positive: 'down' makes a fall green, for weight or cost.
reference{ value: number, label?: string }—A thin reference line with its value and label at the left, such as a goal. The y range always includes it.
selected / onSelectnumber / (index: number) => void—The column at rest, with the band, the big point and the ink axis pill. Defaults to the latest point; a click or Enter pins another one.
colornumber | string1Lead colour: 1–8 for --ds-chart-N with its soft partner, or a CSS colour. Further series take the next palette slots.
heightnumber120Plot height in px, not counting the axis labels under it.
smoothbooleantrueMonotone curve that never overshoots into false peaks; false draws straight segments.
yMin / yMaxnumber—Y range. By default it hugs the data with a little headroom, so small changes stay visible.
format'number' | 'percent' | 'currency' | 'duration' | (n) => string—How values read: a number with the data's decimals, a percent (42 reads 42%), money in `currency`, a duration in seconds (4m 30s), or your function. Without it numbers keep up to two decimals.
locale / currencystring / string'en-US' / 'USD'Language of the number format and the ISO code used by format='currency'.
formatValue(n: number) => string(n) => n.toLocaleString('en-US')Your own number format for the hero, tooltip, reference label, legend and screen-reader table, ahead of `format`.
showLegendbooleantrueWith two or more series, a legend whose values follow the selected or hovered column.
labelstring—Accessible name of the plot and caption of the hidden data table. Defaults to the title.
textobject—Replaces built-in text: open, tip(value, unit), plot(name, count), point(category, parts), noData, category. Named text because labels holds the categories.
replayKeystring | number—Change it to play the entrance again. Changing the categories also replays it; changing only values glides.
className / style / ...restHTMLAttributes—Passed to the card root, which fills its container width.

Accessibility

  • The plot is a focusable group named after the chart. Left and Right move between points, Home and End jump to the ends, Enter pins the column, Escape goes back to the pinned one.
  • Each move is announced through a polite live region; a visually hidden table holds every value.
  • The drawing is hidden from screen readers; the hero, delta and legend are real text.
  • The muted series is told apart by its dotted stroke and legend name, not only by colour.
  • Reduced motion shows the final chart at once and the numbers do not count.

Motion

Entrance waits until 30% of the card is visible. Over 900ms on cubic-bezier(0.22, 1, 0.36, 1) the line draws while its area rises from the baseline and the hero counts; points pop (420ms spring) as the line reaches them; the band rises at 520ms and the ink axis pill pops at 640ms. Hover moves the band and tooltip in 240ms; new data glides over 900ms.

Add it to your project

Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the component next to your own.

AreaChart.jsxarea-chart.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Charts
Trilateration comes with Pro. Its preview shows once you unlock it.