Skip to content
Thrum

Waterfall chart

How a total got from one number to another: a start, the gains and losses in between, and the end. Use it for a cash bridge, a budget against actuals, or the change in users over a month. To compare totals that do not build on each other, use the bar chart.

Install

npx shadcn@latest add @thrum-pro/waterfall-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 WaterfallChartStep = {
  label: string;
  value: number | null;         // change, or the total to set
  kind?: "change" | "total";    // default "change"
};
Sample
[
  { label: "Opening", value: 42000, kind: "total" },
  { label: "Sales", value: 18400 },
  { label: "Refunds", value: -2300 },
  { label: "Closing", value: null, kind: "total" },
]

Props

PropTypeDefaultDescription
datareadonly WaterfallChartStep[]RequiredThe steps in order. A change floats from the running total before it to the one after. A total stands on zero: with a value it sets the running total (a starting balance), with null it shows the sum so far (a subtotal or the end).
labelstringRequiredWhat the running total measures. Read by screen readers and used as the table caption.
formatIntl.NumberFormatOptionsDefault compactHow values are written on the axis, on the bars, in the readout and in the data table. Changes always carry a plus or a minus sign.
localestringDefault "en-US"Locale for number formatting. Fixed by default so the server and the browser print the same text.
valuesbooleanDefault trueWrite each change, or each total, past the end of its bar: above a rise, below a fall. They are left out when the widest one does not fit its slot.
yAxisbooleanDefault trueShow value lines and their labels. The axis always includes zero, and the zero line is solid.
xAxisbooleanDefault trueShow step labels along the bottom. As many as fit are shown, always including the last.
onActiveChange(index: number | null) => void–Called with the index of the step under the cursor, or null when the cursor leaves.
soundbooleanDefault truePlay a tick as the cursor moves between steps, if the visitor has sound on.
emptyLabelstringDefault "No data"Text shown when no step has a value.
classNamestring–Sets the size. The default is full width and 288 pixels tall.

Motion and sound

Motion

  • First draw: each bar grows from where it starts in 250 ms, 40 ms apart, and the connector lines fade in after them.
  • New data with the same number of steps: bars and connectors move to their new places in 400 ms with no overshoot. A different number of steps switches at once.
  • The band behind the active step follows the pointer on a stiff spring.
  • 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 step, 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 step under the cursor, for example “Refunds: −$2.3K, running total $58.1K” or “Closing: total $36.6K”.
  • A visually hidden table carries every step with its change and the running total after it.
  • Gains are green and losses red, and never by colour alone: every change carries a plus or a minus sign on the bar, in the readout and in the table, and the readout names it a gain or a loss. Totals are neutral.
  • A missing change reads “No data” and leaves the running total as it was.
  • The whole plot is the pointer target, so a small change is as easy to read as a large one.
KeysAction
TabFocus the chart. The cursor goes to the last step.
← →Move the cursor one step.
Home / EndJump to the first or last step.
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/waterfall-chart.tsx
Packages
motion
Brings along
Chart foundationsMotion tokensSound engine

Changelog

  1. 1.0.0 · 2026-12-03First 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