Funnel chart
The stages of a conversion, from first visit to purchase, as bars that shrink with each step. Every stage shows its count and its share of the first stage, and the drop from the stage before is written between the bars. For counts that do not flow from one step to the next, use the bar chart.
Install
npx shadcn@latest add @thrum-pro/funnel-chartThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Data shape
type FunnelChartStage = {
name: string;
value: number | null; // null = no data
};[
{ name: "Visited", value: 48200 },
{ name: "Signed up", value: 9640 },
{ name: "Started trial", value: 4120 },
{ name: "Subscribed", value: 1310 },
]Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | readonly FunnelChartStage[] | Required | The stages in order, first to last. Bars are sized against the largest stage, which is usually the first. Negative counts are drawn as zero. |
label | string | Required | What is counted. Read by screen readers and used as the table caption. |
align | "center" | "start" | Default "center" | Bars centred on one line, the classic funnel shape, or lined up at the bottom (columns) or the left (rows) so their lengths compare exactly. |
color | string | Default var(--chart-1) | Any CSS colour for the bars and the bands that join them. |
format | Intl.NumberFormatOptions | Default compact | How counts are written. Shares of the first stage and drops are whole percentages. |
locale | string | Default "en-US" | Locale for numbers. Fixed by default so the server and the browser print the same text. |
onActiveChange | (index: number | null) => void | – | Called with the index of the stage under the cursor, or null when the cursor leaves. |
sound | boolean | Default true | Play a tick as the cursor moves between stages, if the visitor has sound on. |
emptyLabel | string | Default "No data" | Text shown when there are no stages. |
className | string | – | Sets the size. The default is full width and 288 pixels tall. At 480 pixels wide and more the stages are columns, left to right; below that they are rows, top to bottom. |
Motion and sound
Motion
- First draw: each bar grows out from its middle (or its start) in 250 ms, stages 40 ms apart, and the joining bands fade in after them.
- New data with the same number of stages: bars and bands move to their new sizes in 400 ms with no overshoot. A different number of stages, or a switch between columns and rows, draws again at once.
- The band behind the active stage follows the pointer on a stiff spring.
- Reduced motion: the chart appears complete, and changes and the cursor move instantly.
Sound
- A soft tick each time the cursor lands on a different stage, 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 stage under the cursor, for example “Started trial: 4,120, 9% of Visited, 57% drop from Signed up”.
- A visually hidden table carries every stage with its count, its share of the first stage and its change from the stage before.
- Every number is also written on the chart, so nothing depends on colour or on reading a bar's length. A drop is written with a minus sign; a stage larger than the one before gets a plus sign.
- Each stage's whole slot, text included, is the pointer target.
| Keys | Action |
|---|---|
| Tab | Focus the chart. The cursor goes to the last stage. |
| → ↓ | Move the cursor to the next stage. |
| ← ↑ | Move the cursor to the stage before. |
| Home / End | Jump to the first or last stage. |
| 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/funnel-chart.tsx- Packages
motion- Brings along
- Chart foundationsMotion tokensSound engineChart tooltip
Changelog
- 1.0.0 · 2026-12-03First release.