Controls

Sankey Chart

Effect
Preview
Reduced motion

Simulates prefers-reduced-motion for the demo. Off follows your system setting.

Keyboard stepping

Steps focus through the demo with ] and [. Tab, arrows, and Escape stay native so the component behaves as shipped.

Sankey Chart

Monthly budget
FromToValue
SalaryIncome$4.2K
FreelanceIncome$1.3K
DividendsIncome$500
IncomeHome$1.9K
IncomeFood$900
IncomeTravel$700
IncomeSavings$2.5K

Sankey Chart

Soft ribbons that show how amounts flow from one stage to the next.

Installation

npx shadcn@latest add ikislay/pixel-ui/sankey-chart

How to use

import { SankeyChart } from "@/components/ui/sankey-chart"
const nodes = [
{ id: "salary", label: "Salary" },
{ id: "freelance", label: "Freelance" },
{ id: "income", label: "Income" },
{ id: "rent", label: "Rent" },
{ id: "savings", label: "Savings" },
]
const links = [
{ source: "salary", target: "income", value: 4200 },
{ source: "freelance", target: "income", value: 1300 },
{ source: "income", target: "rent", value: 1900 },
{ source: "income", target: "savings", value: 3600 },

Source Code

// Loading…

Props

Options you can pass to customize this component.

Prop
Type
Description
nodes*
{ id: string; label?: string; color?: string }[]

The stages. Each one lands in the column of its longest path from a source, top to bottom in the order given.

links*
{ source: string; target: string; value: number }[]

The flows between stages, by id. Links to unknown ids, to themselves or with no value are skipped.

label*
string

Names the chart for screen readers and captions its data table.

format
(value: number) => string

Formats values wherever the chart shows them. Defaults to short numbers like 12.4K.

height
number

Height in pixels. The width fills the parent, with room for labels on both sides.

nodeWidth
number

Width of each stage's rounded bar in pixels.

className
string

Merged onto the root element.