Sankey chart
Flows between steps as bands as thick as their value. The hovered node or flow keeps every way through it bright while the rest step back, and new data moves every node and flow from where it is.
Examples
Visitors
Flows from where visitors came, to the page they opened first, to whether they started a trial. Hover a node or a flow to light every way through it; another month moves every node and flow from where it is.
Data order
sort="data" keeps each column in the rows’ order, as a budget reads, and linkColor="source" paints each flow in its source’s colour.
Colours of your own
A node’s color in the config, here the destructive colour where trials drop off; the flows into it fade to it.
Installation
npx shadcn@latest add https://kinoui.com/r/sankey-chart.json- Files
lib/dates.tslib/chart-math.tslib/chart-scale.tslib/chart-frame.tslib/refs.tslib/reduce-motion.tslib/resize.tslib/live.tsxlib/chart-live.tslib/chart-live-clock.tsxlib/scroll.tslib/swap.tsxlib/popup.tslib/glide.tsxlib/keys.tsxcomponents/kino/kbd.tsxcomponents/kino/tooltip.tsxlib/cut.tsxlib/number-format.tslib/roll.tsxlib/run-progress.tscomponents/kino/animated-number.tsxlib/announce.tscomponents/kino/spinner.tsxcomponents/kino/button.tsxlib/controllable.tslib/chart-root.tsxlib/chart-state.tslib/chart-agent.tslib/chart-base.tsxlib/chart-cartesian-reader.tslib/chart-cartesian.tsxlib/chart-list.tsxlib/chart-list-reader.tslib/chart-tree-reader.tslib/chart-flow-reader.tslib/chart-grid-reader.tslib/highlight.tscomponents/kino/chart.tsxlib/chart-flows.tslib/placeholder.tscomponents/kino/sankey-chart.tsx- Packages
@ui-sdk/core@ui-sdk/reactclass-variance-authorityd3-arrayd3-sankey- Global CSS
- the feels, the density tokens, the shape tokens and the success and warning colours
New to Kino? Installation covers what your project needs first and the @kino namespace.
The CLI keeps any of these colours your project already has, such as the chart colours shadcn init writes. To use Kino’s, set them in your global CSS:
:root { --chart-1: oklch(0.42 0.1 248); --chart-2: oklch(0.53 0.12 222); --chart-3: oklch(0.6 0.11 185); --chart-4: oklch(0.65 0.17 132); --chart-5: oklch(0.72 0.154 106.7); --chart-accent: oklch(0.795 0.171 71.2);}.dark { --chart-1: oklch(0.6 0.15 255); --chart-2: oklch(0.7 0.13 222); --chart-3: oklch(0.79 0.13 185); --chart-4: oklch(0.82 0.15 128); --chart-5: oklch(0.72 0.154 106.7); --chart-accent: oklch(0.795 0.171 71.2);}API reference
SankeyChart
The chart: a <figure> named by label, which lays out and draws the nodes and flows and holds the chart’s parts. Each node stands in a column from the reading start, as tall as what passes through it, with its name and value beside it where they fit: before the first column and after the last where they have the room, else after the node. Other props go to the figure. The props from data to messages are the ones every chart takes, less those for a value axis, an order, patterns and a pick.
ChartTooltip
What is under the pointer or the focus, in the chart’s own words: on a chart with series, the values of the category or the time. It shows at once and slides from one to the next. Other props go to its popup.
ChartLegend
A toggle for each series that shows and hides it. Pointing at one, or focusing it, brings its series forward. Takes position, top or bottom.
Data attributes
CSS variables
Accessibility
- The nodes are one stop in the tab order: a slider over the nodes, column by column. Up and Down step through a column, Left and Right go to the nearest node in the column before or after, following the reading direction, Page Up and Page Down go to the top and bottom of the column, and Home and End to the first and last node. Each node’s name, value and share of the whole are read as the slider’s value.
- A hidden table holds every flow, from and to, with its value and its share of where it came from, for screen readers and for copying.
- Every node is named beside it where it fits, and in the tooltip, the table and the slider, so none relies on colour alone. Forced colours draw the nodes in the text colour and the flows in a grey of the system’s.
- Touch shows the tooltip of the node or flow under the finger.
- When the system asks for less motion, nodes and flows land at once, with no move, and only their colours and opacity fade.
- The chart is a
<figure>named bylabel. - Escape closes the tooltip and nothing above the chart.
- The legend’s toggles say whether each series shows. When every series is hidden, a button shows them all again and takes the focus.
For agents
What an agent reads on this example with snapshot(), and the actions it can call with act().
The Agent bridge page sets up snapshot() and act() in your app.