shadcn Sankey Chart: What to Check and How to Install One
The shadcn/ui charts don't include a Sankey diagram. It's one of the most requested additions: the GitHub issue asking for it has been open since August 2025, and most of its comments are people asking for an update. Recharts, which the shadcn charts are built on, has a Sankey component, but it is a low-level primitive: you pass nodes and links by array index and style everything yourself.
This guide covers what a Sankey is for, what to check in any Sankey component before you show it to a finance team, and how to install one in a shadcn project.
What a Sankey chart is for
A Sankey shows how a quantity flows from sources to destinations. The width of each band is proportional to the amount. Typical uses in a product or finance dashboard:
- Income statements: revenue splits into cost of revenue and gross profit, gross profit into operating expenses and operating income.
- Budget allocation: a total budget into departments, then into teams.
- User flows: sign-ups into activated, trial and churned users.
- Energy or material flows: inputs, conversions and losses.
If the question is "where did it go?", a Sankey is a good fit. If the question is "how did it change over time?", it isn't: use a stacked area chart or a waterfall chart.
The checklist
- Names, not indexes. You should be able to pass flows as
{ source: "Revenue", target: "Gross profit", value: 9.2 }. Index-based data (source: 0, target: 3) breaks silently when someone reorders the node list. - It checks that flows balance. What flows into a node should equal what flows out (unless it's a final node). When it doesn't, the chart should say so: "Revenue receives 12.4 but sends 12.0 (unallocated 0.4)". A Sankey that hides this is presenting numbers that don't add up.
- It refuses cycles. A flow that loops back (A → B → A) can't be drawn as a Sankey. The chart should show an error, not a tangle.
- Values on the nodes. Readers want "Operating income $1.8m", not just a band width to estimate.
- One thing highlighted. Most Sankeys have one path that matters. Colour that path and keep the rest muted, or the eye has nowhere to go.
- A table view. Finance teams will ask for the numbers behind the bands.
Install one with the shadcn CLI
ChartslibraryUI's Sankey chart passes all six. It's part of Pro. After buying, install it with your access key:
pnpm dlx shadcn@latest add @chartslibraryui/sankey-chartnpx shadcn@latest add @chartslibraryui/sankey-chartyarn dlx shadcn@latest add @chartslibraryui/sankey-chartbunx --bun shadcn@latest add @chartslibraryui/sankey-chartThe data is a list of flows, using names:
const flows = [
{ source: "Subscriptions", target: "Revenue", value: 10.6 },
{ source: "Services", target: "Revenue", value: 1.8 },
{ source: "Revenue", target: "Gross profit", value: 9.2 },
{ source: "Revenue", target: "Cost of revenue", value: 3.2 },
{ source: "Gross profit", target: "Operating expenses", value: 7.4 },
{ source: "Gross profit", target: "Operating income", value: 1.8 },
];<SankeyChart
title="Sales & marketing takes the largest share of gross profit"
data={flows}
format={{ kind: "currency", unit: "m", decimals: 1 }}
highlight={["Operating income"]}
/>Imbalances above 0.5% are reported under the chart (change it with tolerance), cycles are shown as an error, nodes show their value when there's room (and always in the tooltip), and every flow is a row in the table view.
Keep Sankeys readable
- Around 20 flows at most. Group small flows into "Other". Past that, a table is easier to read.
- Three or four stages. Each extra column of nodes makes the bands thinner.
- Order matters. Put the largest flows at the top and keep the same order in every stage, so bands cross as little as possible.
- Say the unit and the period in the subtitle: "Last twelve months, USD millions".
Related
- Waterfall chart guide: the other way to show how a total breaks down
- Funnel chart: for a single path with drop-off at each step
- The best shadcn chart components (2027)