Sankey flowPro
Volumes flowing between stages as ribbons. Hover a stage to trace everything that passes through it.
$
pnpm dlx shadcn@latest add @lode/sankey-flowLive preview
Where visitors go
17.0k visitors · 19.4% became paid
When to use
- Showing how a volume splits and merges across stages: traffic to signups, budget to teams, energy to uses.
- Finding the biggest leaks between one step and the next.
When not to use
- A single linear path with drop-off: use the funnel chart.
- Cycles (A → B → A): a Sankey needs flows that move forward.
Installation
$
pnpm dlx shadcn@latest add @lode/sankey-flowPro components need an API key and the registry in components.json. See CLI and API keys.
1Install the dependencies
npm install motion2Copy the source into your project
Usage
Import it from @/components/ui/sankey-flow after installing.
example.tsx
import { SankeyFlow } from "@/components/ui/sankey-flow";
const nodes = [
{ id: "search", label: "Search" },
{ id: "direct", label: "Direct" },
{ id: "trial", label: "Trial" },
{ id: "paid", label: "Paid" },
];
const links = [
{ source: "search", target: "trial", value: 4200 },
{ source: "direct", target: "trial", value: 1800 },
{ source: "trial", target: "paid", value: 1900 },
];
export function Flow() {
return <SankeyFlow nodes={nodes} links={links} columns={["Source", "Trial", "Outcome"]} />;
}API reference
SankeyFlow
Stages as bars, flows as ribbons sized by volume. Columns come from the links.
| Prop | Type | Default | Description |
|---|---|---|---|
| nodes | SankeyNode[] | – | { id, label, color? }. Colour defaults to the chart palette. |
| links | SankeyLink[] | – | { source, target, value }. Links must point forwards; the column of each node is worked out from them. |
| columns | string[] | – | Titles above each column. |
| height | number | 360 | Height in px. Width fills the container. |
| format | (n) => string | – | Values beside nodes and in tooltips. |
| particles | boolean | true | Dots drifting along ribbons, more on bigger flows. |
Keyboard interactions
| Keys | Action |
|---|---|
| Tab | Move between stages |
| Focus a stage | Highlights everything flowing into and out of it |
Accessibility
- Each stage is focusable with its value and share of the total.
- The chart has a text summary of the total and the number of stages.
Motion
- Particles move along each ribbon in proportion to its volume.
- Particles are off for reduced motion and pause when the chart is off screen.
Responsive behavior
- Width follows the container with a ResizeObserver; ribbons and labels re-lay out.
Performance
- Particles are written to the DOM each frame without React re-renders; about 70 dots in total.
Notes for AI
- Give every link a positive value; nodes are sized by the larger of what flows in and out.
- Use muted colours (var(--muted-foreground)) for drop-off nodes so the main path stands out.
This page as Markdown, for assistants and coding agents:
/components/sankey-flow/markdownThe full library index for assistants is at /llms.txt.
Related
Lode·227 doc pages·llms.txt