Skip to content
Sign upPro
DataSankey chartMenu

Sankey chart (Pro)

ProIncluded in $99

Where things flow, step by step: ribbons blend from one step's color to the next, and pointing at a step lights every flow through it with dots traveling the way things move.

ProA week of support chats from channel to intent to outcome. Point at Bug report to see where bugs end up.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/sankey-chart

Needs chatcn Pro

This command works with a Pro license, along with every Pro component.

Or start free: sign up and get three Pro components on us, with a new one every month.

Usage

tsx
import { SankeyChart } from "@/components/ui/chatcn/pro/sankey-chart"

<SankeyChart
  title="Where support chats went this week"
  columns={["Channel", "Intent", "Outcome"]}
  nodes={[
    { id: "web", label: "Web" },
    { id: "bug", label: "Bug report" },
    { id: "ai", label: "Answered by AI", tone: "good" },
    { id: "left", label: "Left unanswered", tone: "bad" },
  ]}
  links={[
    { source: "web", target: "bug", value: 1380 },
    { source: "bug", target: "ai", value: 1240 },
    { source: "bug", target: "left", value: 140 },
  ]}
  unit="chats"
/>

Steps are placed in columns by their longest path from a source, so every flow runs left to right, and ribbons are stacked in the order of the step at their other end so they cross as little as they can. Every step takes a palette color in reading order (--chatcn-chart-1 onward) unless it has its own color or a tone, and each ribbon blends from the color of the step it leaves to the step it reaches, so you can read where a flow came from and where it went. Give outcomes a tone (good, bad, warn, neutral) and they read by meaning without a legend. Names of the first and last columns sit outside the plot in gutters sized to fit, so they never sit on a ribbon. Everything rests as a quiet tint: point at a step and every flow on a path through it lights, upstream and down, with dots traveling the way things move; point at a ribbon and a card follows the pointer with its amount, its share of where it came from and its share of everything. The plot keeps a minimum width of 520 px and scrolls sideways inside its card below that. The table button shows every link as a table, and a screen reader table is always there.

Examples

States

ProTwo columns of spend, loading, empty and a failed load.

Props

PropTypeNotes
nodesSankeyNode[]{ id, label, color?, tone? }; tone is good, bad, warn or neutral
linksSankeyLink[]{ source, target, value }
title, descriptionReactNodeThe caption
headlineReactNodeA large number under the title, such as a ChartHeadline
columnsstring[]Names over the columns, left to right
linkColor"gradient" | "source" | "target"How ribbons take color. Default gradient
flow"hover" | "always" | "off"Dots along the lit ribbons. Default hover; off under reduced motion
nodeValue"value" | "share" | "none"What follows each name. Default value
unit, valueFormatstring, DataValueFormatHow amounts read
heightnumberDefault 320
loading, error, onRetryLoading keeps the final height
labelsPartial<SankeyChartLabels>Every string, for translation

Keyboard

KeyAction
TabFocus the chart; the first step is read out
Arrow up, downPrevious or next step in the column
Arrow left, rightThe nearest step in the column before or after
EscapeClear the highlight

Accessibility

  • The chart is an image summarized in words, with a table of every flow for screen readers.
  • The readout above the plot says what is pointed at or focused, in words and numbers.
  • Color is never the only cue: steps and amounts are labelled.

Motion

Flows draw in from the left once, over 900 ms with the kit's ease out, and steps grow from their baseline. Highlights fade over 200 ms. On lit ribbons, dots travel along the flow (stroke dash offset only) to show direction. Under reduced motion it appears drawn and nothing travels.