Calm motion: animations on this site only fade, with no movement
Sankey
Flows between steps, as bands
Shows how an amount moves through steps and splits, for example where visitors came from and where they went, or where a budget goes. The width of each band is its amount. For one path that only gets narrower, use the funnel. For parts of one whole, use the treemap or the meter group.
Basic
| From | To | Value |
|---|---|---|
| Search | Episode page | 42k |
| Social | Episode page | 31k |
| Direct | Episode page | 12k |
| Episode page | Started | 51k |
| Episode page | Left | 34k |
| Started | Finished | 38k |
| Started | Left | 13k |
linksis a list of{ source, target, value }. A node is any id that a link names, so you need no list of nodes. A flow of 0 and a flow from a node to itself are left out.nodesis optional:{ id, label, color }. It sets the text, the color, and the order of the nodes in each column.- Each node goes in the column of its longest path from a start. A node with no flow out goes in the last column, so all the results line up at the end.
- A node's height is the larger of its flow in and its flow out. Each band takes the color of its source, and a hover shows the flow.
- Colors go through the chart colors in order. Set
coloron a node to a token name or any CSS color. The labels and values are in the text color, so the chart is readable without color. - The chart draws at the width of its container, measured in the browser, and
heightsets the height (default 320). Text is never stretched. - The chart is hidden from screen readers, and a table of the flows (from, to, value) is read in its place.
labelnames the table. formatsets the text of a value. Change the column names withlabelsor a label pack:from,to, andvalue.- The chart is drawn as plain SVG. There is no chart library to install.
Usage
ts
import { BlessSankey, type BlessSankeyLink, type BlessSankeyNode } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
links* | BlessSankeyLink[] | — | the flows; a node is any id that a link names |
nodes | BlessSankeyNode[] | [] | labels, colors, and order for the nodes; optional |
height | number | 320 | |
format | ((v: number) => string) | — | text for one value, for example `(v) => v.toLocaleString()` |
label | string | "Flows" | names the chart and its table for screen readers |
labels | Partial<{ from: string; to: string; value: string; }> | — |