Sankey Chart

Preview

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/sankey-chart

API Reference

SankeyChart

nodes
readonly SankeyNode[]
Default—
links
readonly SankeyLink[]

Weighted flows between node ids. Links that would close a loop are left out.

Default—
label?
string
Default—
formatValue?
((value: number) => string)
Default—
colors?
readonly string[]

Palette for nodes without their own color, in node order.

Default—
nodeWidth?
number

Node bar width in px.

Default—
nodePadding?
number

Space between nodes in a column, in px.

Default—
activeId?
string | null

Highlighted node or link id. Controlled. Link ids default to `source:target`.

Default—
defaultActiveId?
string | null
Default—
onActiveChange?
((id: string | null) => void)
Default—
labels?
Partial<{ label: string; tableCaption: string; flow: string; value: string; shareOfSource: string; flowRow: string; nodes: string; nodeFlows: string; tooltipFlows: string; from: string; to: string; more: string; linkShare: string; noFlows: string; empty: string; }>

Override any built-in string.

Default—
className?
string
Default—

SankeyChartPlot

className?
string

Sets the plot height; default 20rem. The layout follows its measured size.

Default—
showValues?
boolean

Show each node's value under its label when there is room.

Defaulttrue

SankeyChartTooltip

className?
string
Default—
side?
"top" | "right" | "bottom" | "left"
Defaulttop
children?
ReactNode | ((active: SankeyActive) => ReactNode)

Custom content for the highlighted node or flow.

Default—

Updated