Skip to content
Thrum

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-chart

This is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.

Data shape

Type
type AreaChartPoint = {
  label: string;        // axis name
  value: number | null; // null = gap
};
Sample
[
  { label: "Mon", value: 120 },
  { label: "Tue", value: 180 },
  { label: "Wed", value: null },
  { label: "Thu", value: 260 },
]

Props

PropTypeDefaultDescription
datareadonly AreaChartPoint[]RequiredPoints in order, oldest first.
labelstringRequiredWhat the chart measures. Read by screen readers and used as the table caption.
colorstringDefault var(--chart-1)Any CSS colour for the line and fill.
formatIntl.NumberFormatOptionsDefault compactHow values are written on the axis, in the readout and in the data table.
localestringDefault "en-US"Locale for number formatting. Fixed by default so the server and the browser print the same text.
yAxisbooleanDefault trueShow value lines and their labels.
xAxisbooleanDefault trueShow 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.
soundbooleanDefault truePlay a tick as the cursor moves between points, if the visitor has sound on.
emptyLabelstringDefault "No data"Text shown when there is nothing to draw.
classNamestring–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.
KeysAction
TabFocus the chart. The cursor goes to the latest point.
← →Move the cursor one point.
Home / EndJump to the first or last point.
EscHide the cursor.

Source

SourcePro

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. 1.0.0 · 2026-12-02First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor