Funnel Chart
React funnel chart with horizontal or vertical stages, conversion and drop-off between stages, an optional comparison outline and bars that spring to new data.
Installation
npx shadcn@latest add @minidev/funnel-chart
MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/funnel-chart.json
Usage
import { FunnelChart } from "@/components/ui/funnel-chart"
export function Example() {
return (
<FunnelChart />
)
}
API reference
| Prop | Type | Default |
|---|---|---|
| stagesStages from the top of the funnel down. | FunnelStage[] | - |
| datasetsDatasets to switch between with a segmented control. Ignored when `stages` is set. | FunnelDataset[] | DATASETS |
| orientation"auto" is horizontal when the container is at least 480px wide, vertical below that. | "horizontal""vertical""auto" | "auto" |
| titleChart title; also the figure's accessible name. | string | "Visitors to paid" |
| compareLabelLegend text for the comparison series. | string | "Last month" |
| formatFormats values in the bars and the table. | (value: number) => string | defaultFormat |
| showCompareDraw the comparison outline when stages carry `compare`. | boolean | true |
| className | string | - |
When to use
Use for signup and checkout funnels. Pass stages for one series, or datasets to add a segmented switch between them. Screen readers get a full data table. For a compact list of bars use FunnelSteps; for flows that branch use SankeyChart.
Keyboard interactions
| Key | Action |
|---|---|
| Tab | Moves focus to the dataset switch, when datasets has more than one entry and stages is not set. |
| ArrowLeftorArrowRight | In the dataset switch, selects the previous or next dataset. |
Accessibility
- The chart is a
<figure>labelled by its title. All bars and labels arearia-hidden. - A visually hidden
<table>lists each stage's value, step conversion and drop-off, the comparison column when present, and an overall conversion row. - Bars spring to new sizes when the data changes; under reduced motion they jump to the new size.
Frequently asked questions
How are conversion and drop-off calculated?
Between each pair of stages, step conversion is value / previous value and drop-off is previous value - value. The large figure in the header is overall conversion: the last stage divided by the first. Rates under 10% show one decimal.
How do I compare against last month?
Give each stage a compare value and set compareLabel. Each bar then gets a dashed outline at the comparison size, the header adds the comparison's overall rate, and the hidden table gets a column for it. Turn it off with showCompare={false}.
Why does the legend say "All" when I pass my own stages?
The legend names the main series after the selected dataset, and the default datasets start on "All". When you pass stages with compare, pass datasets={[{ label: "This month", stages }]} instead, so the legend reads your label.
Does it switch to vertical on mobile?
With the default orientation="auto", yes: a ResizeObserver lays the stages out as rows when the chart's box is under 480px wide, and as columns above that. Pass "horizontal" or "vertical" to fix the layout.
Dependencies
npm
Built from
Examples
Fixed stages
Pass stages for a single funnel; the segmented control disappears and showCompare false hides the comparison legend.
Vertical with comparison
orientation vertical lists stages as rows, compare values draw the dashed outline, and format keeps full numbers instead of compact ones.