Area chart
One metric over time, drawn as a filled line. Use it when the amount matters as much as the trend: revenue, sessions, usage. For several lines on one plot, use the line chart; for a trend with no axes, use the sparkline.
Install
npx shadcn@latest add @thrum-pro/area-chartThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Data shape
type AreaChartPoint = {
label: string; // axis name
value: number | null; // null = gap
};[
{ label: "Mon", value: 120 },
{ label: "Tue", value: 180 },
{ label: "Wed", value: null },
{ label: "Thu", value: 260 },
]Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | readonly AreaChartPoint[] | Required | Points in order, oldest first. |
label | string | Required | What the chart measures. Read by screen readers and used as the table caption. |
color | string | Default var(--chart-1) | Any CSS colour for the line and fill. |
format | Intl.NumberFormatOptions | Default compact | How values are written on the axis, in the readout and in the data table. |
locale | string | Default "en-US" | Locale for number formatting. Fixed by default so the server and the browser print the same text. |
yAxis | boolean | Default true | Show value lines and their labels. |
xAxis | boolean | Default true | Show point labels along the bottom. As many as fit are shown, always including the first and last. |
onActiveChange | (index: number | null) => void | – | Called with the index of the point under the cursor, or null when the cursor leaves. Use it to sync another chart or a table row. |
sound | boolean | Default true | Play a tick as the cursor moves between points, if the visitor has sound on. |
emptyLabel | string | Default "No data" | Text shown when there is nothing to draw. |
className | string | – | Sets the size. The default is full width and 256 pixels tall. |
Motion and sound
Motion
- First draw: the line and fill are revealed left to right in 700 ms at constant speed, like a pen on a strip chart.
- New data with the same number of points: the shape morphs to the new values in 400 ms with no overshoot. A different number of points switches at once.
- The cursor and its dot follow the pointer on a stiff spring, so they feel attached but never jitter.
- Reduced motion: the chart appears complete, and data changes and the cursor move instantly.
Sound
- A soft tick each time the cursor lands on a different point, at most one every 40 ms.
Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works
Accessibility
- The chart is one tab stop. It is exposed as a slider whose value text is the point under the cursor, for example “Tue: 180”.
- A visually hidden table carries every point, with the label as its caption.
- The whole plot is the pointer target, so the line itself never has to be hit.
| Keys | Action |
|---|---|
| Tab | Focus the chart. The cursor goes to the latest point. |
| ← → | Move the cursor one point. |
| Home / End | Jump to the first or last point. |
| Esc | Hide the cursor. |
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/area-chart.tsx- Packages
motion- Brings along
- Chart foundationsMotion tokensSound engine
Changelog
- 1.0.0 · 2026-12-02First release.