# Waterfall (/docs/charts/waterfall)

60 opening, five signed steps, 87 at the close. Waterfall is the P&L bridge in a table cell: one bar per delta, each
starting where the last one left off. Sign is encoded by vertical direction from the running level AND by valence color,
never color alone.

```tsx
<Waterfall
  data={[
    { label: "Product", value: 42 },
    { label: "Services", value: 18 },
    { label: "Refunds", value: -12 },
    { label: "Opex", value: -26 },
    { label: "FX", value: 5 },
  ]}
  open={60}
  title="Net income bridge"
  width={220}
  height={30}
/>
```

## Install

```tsx
import { Waterfall } from "@microcharts/react/waterfall";

<Waterfall data={steps} open={60} title="Net income bridge" />
```

Setup (package + stylesheet): [Quickstart](/docs/quickstart#set-up-with-an-ai-agent) or paste [`/agent-setup.md`](/agent-setup.md) into your agent.

## Try it

```tsx
import { Waterfall } from "@microcharts/react/waterfall/interactive";

<Waterfall
  data={steps}
  open={60}
/>
```

## When to use it

Use it for P&L bridges in table cells and net-change decomposition in KPI cards. For unordered category comparison use
MiniBar, and keep any one bridge under about 8 steps.

## Sizing

**no step labels**

```tsx
<Waterfall data={steps} open={60} label="none" />
```

**P&L rows**

```tsx
{quarters.map((q) => (
  <Waterfall key={q.id} data={q.steps} open={q.open} title={q.name} />
))}
```

**cost bridge (down is good)**

```tsx
<Waterfall data={steps.map((d) => ({ label: d.label, value: -d.value }))} positive="down" />
```

## Variants

```tsx
// label="delta" is the default — each step's signed value sits in a band below
// the plot. When labels would collide, the biggest movers win — a deterministic
// drop-out, never a random overlap. Pass label="none" to drop the band.
<Waterfall data={steps} open={60} />
<Waterfall data={steps} open={60} totalBar={false} />
```

The zero-anchored total bar stays on by default, because floating bars alone can't be checked against a real total.
Hairline connectors carry the running level between steps without adding ink.

```tsx
// cost breakdowns invert valence — decreases are wins
<Waterfall
  data={[
    { label: "Cloud", value: -8 },
    { label: "Headcount", value: 14 },
    { label: "Vendors", value: -5 },
    { label: "Travel", value: -3 },
  ]}
  open={40}
  positive="down"
/>
```

## Edge cases

```tsx
// a bridge that only falls — the domain extends below zero and the
// zero-anchored total bar hangs beneath the baseline
<Waterfall
  data={[
    { label: "Q1", value: -20 },
    { label: "Q2", value: -35 },
    { label: "Q3", value: -10 },
  ]}
  open={0}
/>
```

```tsx
// a zero delta renders a visible 1-unit neutral tick at the running level —
// "no change" is a statement, not a gap
<Waterfall
  data={[
    { label: "Product", value: 30 },
    { label: "Flat", value: 0 },
    { label: "Refunds", value: -12 },
  ]}
  open={50}
/>
```

## Four homes

**In a sentence**

```tsx
<p>
  Net income bridged from $60k to $87k this quarter{" "}
  <span className="mc-inline">
    <Waterfall data={steps} open={60} width={100} height={16} summary={false} />
  </span>{" "}
  — Product and
  Services carried it past Refunds and Opex.
</p>
```

**In a table cell**

```tsx
<td>
  <Waterfall data={unit.steps} open={unit.start} />
</td>
```

**In a KPI card**

```tsx
<div className="kpi">
  <span className="figure">$87k</span>
  <span className="unit">from $60k</span>
  <Waterfall data={steps} open={60} />
</div>
```

**In a tab header**

```tsx
<button className="tab">
  Revenue <Waterfall data={steps} open={60} />
</button>
```

## Accessibility

The accessible name states the endpoints and the split: **"From 60 to 87 over 5 steps: +65 gains, −38 losses."** The
interactive entry steps through the bridge (**"Refunds: −12, running 108."**).

The interactive entry follows the shared [interaction contract](/docs/accessibility#one-interaction-contract):
arrow keys rove between units on both axes, `Home` and `End` jump to the ends, and a click, tap, `Enter` or
`Space` selects a unit — pinning its readout so it survives blur, until you select it again, press `Escape`, or
press outside the chart. On touch, a tap pins and a drag scrubs.

## Props

| Prop | Type | Description |
| --- | --- | --- |
| `data` (required) | `{ label; value }[]` | Signed deltas in order. |
| `open` | `number` | Opening level (prior-period close). |
| `totalBar` | `boolean` | Zero-anchored closing total bar (default on). |
| `positive` | `"up" \| "down"` | "down" = decreases are good (cost breakdowns). |
| `label` | `"none" \| "delta"` | "delta" (default) prints each step's signed value in a band below the plot; the biggest movers win when labels would collide. |
| `animate` | `boolean` | (interactive) Opt-in entrance motion when the chart mounts client-side — add `import "@microcharts/react/motion"` once. Inert on the server, on hydrated server HTML, and under `prefers-reduced-motion`. |

Plus the shared grammar — `data`, `domain`, `color`, `title`, `summary`, `format` — and the layout props (`width`, `height`, `className`, `style`) that every chart accepts. Interactive entries also share `animate` and `live`, and — wherever a chart has more than one navigable unit — `onActive`, `onSelect`, `selectedIndex` and `defaultSelectedIndex`; and — wherever the chart shows a hover value — `readout`. See [the shared grammar](/docs/quickstart#the-shared-grammar).
