Conversion step by step: each step's value and share, the flow narrowing between them and what dropped. Plain HTML and SVG, no chart library.
$ pnpm dlx shadcn@latest add @dashral/funnel-chartInstallation
$ pnpm dlx shadcn@latest add @dashral/funnel-chartAdds the component, the components it builds on, its npm packages and the theme tokens it uses. Or by its full URL: https://dashral.com/r/funnel-chart.json
When to use
- Steps people go through in order, and how many make it to each: visits to payments, sign-ups to active teams.
When not to use
- Parts of one whole: Donut Chart.
- Values that don't follow one another: Bar Chart or Bar List.
Usage
Each step's label and value; the percentages and what dropped come from the values.
import { FunnelChart } from "@/components/dashral/funnel-chart"
export default function CheckoutFunnel() {
return (
<FunnelChart
data={[
{ label: "Visits", value: 8200 },
{ label: "Carts", value: 2400 },
{ label: "Paid", value: 960 },
]}
aria-label="Checkout funnel"
/>
)
}Using the npm package? Import from @dashral/ui/components/funnel-chart instead, here and in the examples; the rest is the same.
Examples
Share of the step before
percent="previous" so the weakest step stands out, with compact numbers.
API reference
FunnelChart
Also takes every prop of <div>(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
data | { key?: string; label: string; value: number }[]The steps in order, the first the widest. Required. | — |
percent | "first" | "previous"What the percentage under each value is of: the first step, or the step before. | "first" |
showLost | booleanWhat dropped since the step before, written in the space above each bar. | true |
height | numberThe bars' height at the first step, in pixels. | 200 |
color | stringAny CSS color for the bars and the flow between them. | "var(--chart-1)" |
locale / formatOptions | string / Intl.NumberFormatOptionsHow values are written. | LocaleProvider's |
aria-label | stringWhat the chart shows. | "Funnel chart" |
classNames | { step?, bar? }Classes for each step's column and its bar. | — |
Accessibility
- role="figure" with your label around an ordered list of the steps: each one's label, value and share are text, so nothing depends on the bars.
- After the first step, screen readers also hear how many of the step before carried on and how many dropped.
- In right-to-left the steps run leftwards and the flow follows them.
Motion
- The bars rise in one after another, each value rising into its line with its bar (Text Reveal), and the flow fades in behind them; new data eases the bars and the flow to their new heights while every number counts to its new value. Still with reduced motion.