UI

Sankey flow

Multi-stage flow ribbons with drifting particles and end-to-end path tracing on hover or keyboard focus.

import { SankeyFlow } from '@uthereal/ui/sankey-flow'

Sankey flow playground

Signup journey

Signup journey
FromToValueShare of source
OrganicActivated3,380 people65%
PaidActivated1,990 people51%
ReferralActivated1,240 people73%
ActivatedFree4,690 people71%
ActivatedPro1,920 people29%
OrganicNot activated1,820 people35%
PaidNot activated1,910 people49%
ReferralNot activated460 people27%
Loading interactive preview…

Overview

A Sankey flow diagram shows how a quantity splits and recombines across stages as smooth cubic Bezier ribbons. Each node displays its label and total value, calculated as the larger of its inflow and outflow. First-column sources take the first four chart series hues (series1 to series4) and tint the ribbons they emit; later sources and intermediate flows use neutral ink. Pointing at or focusing any node or ribbon pours its upstream and downstream share through the entire journey while dimming unrelated flows and showing a floating tooltip. A native data table lists every flow with its value and share of source.

Use a Sankey flow diagram to trace conversion funnels with branches, budget allocations, or traffic paths across three to five stages. For a strict single-parent hierarchy, use a treemap. For a simple linear comparison without branching, use a bar chart.

Usage

import { SankeyFlow } from '@uthereal/ui/sankey-flow'

export function SignupJourney() {
  return (
    <SankeyFlow
      label="Signup journey"
      columns={['Source', 'Activation', 'Plan']}
      unit="people"
      totalLabel="signups"
      nodes={[
        { id: 'organic', label: 'Organic' },
        { id: 'paid', label: 'Paid' },
        { id: 'activated', label: 'Activated' },
        { id: 'inactive', label: 'Not activated' },
        { id: 'free', label: 'Free' },
        { id: 'pro', label: 'Pro' },
      ]}
      links={[
        { source: 'organic', target: 'activated', value: 3380 },
        { source: 'organic', target: 'inactive', value: 1820 },
        { source: 'paid', target: 'activated', value: 1990 },
        { source: 'paid', target: 'inactive', value: 1910 },
        { source: 'activated', target: 'free', value: 3860 },
        { source: 'activated', target: 'pro', value: 1510 },
      ]}
    />
  )
}

Keep node id values stable across datasets so switching periods morphs node bars and ribbons in place instead of redrawing. Links must reference declared node IDs and form a directed acyclic graph without self-loops or cycles. Pass particles and onParticlesChange to control the built-in Flow toggle from the host.

Examples

Multi-stage currency allocation with explicit columns

Assign column on nodes to pin stages across four columns, including flows that skip an intermediate stage. Pair valueFormat with four source nodes to display currency totals and all four categorical source hues.

Annual budget allocation

Annual budget allocation
FromToValueShare of source
EngineeringInfrastructure$240,00039%
OperatingEngineering$620,00063%
EngineeringProduct R&D$380,00061%
SubscriptionsOperating$420,000100%
EnterpriseOperating$310,00078%
Usage feesOperating$165,000100%
ServicesOperating$85,000100%
Go-to-marketDemand gen$360,000100%
OperatingGo-to-market$360,00037%
EnterpriseReserve$90,00023%
ReserveTreasury$90,000100%

Behavior

Nodes keep their declared top-to-bottom order within each column and relax across six passes toward the value-weighted center of connected neighbors. Columns default to each node's longest distance from a source unless pinned with column. Keep columns to 12 nodes or fewer so small flows remain readable.

Tracing assumes proportional mixing at each node, multiplying upstream and downstream shares end to end through every connected ribbon. Tracing from a first-column source pours in that source's series hue; tracing from a later stage pours in the theme accent.

On wide layouts, the final column places its labels in a sized end gutter (48–120 px) so labels do not share gaps with ribbons. Below 420 px container width, the diagram switches to an upright vertical layout (height at least 480 px): stages flow top to bottom, column headers hide, and node labels sit directly beneath each horizontal bar. Touch taps trace a node or ribbon and tap again to clear. When there are no positive links, the plot displays emptyLabel ("No flows yet").

API reference

These serializable arguments and defaults come directly from the component schema.

ArgumentType / defaultDescription
labelstringDefault: "Sankey flow"Names the diagram for assistive technology and captions the data table when title is omitted.
titlestring—Optional visible figure heading above the diagram. Omit it to render the diagram without a heading while keeping label for assistive technology.
descriptionstring—One or two sentences on what the chart shows, below the title; omit it when the title says enough.
nodesSankeyNode[]Default: [{"id":"organic","label":"Organic"},{"id":"paid","label":"Paid"},{"id":"activated","label":"Activated"},{"id":"inactive","label":"Not activated"},{"id":"free","label":"Free"},{"id":"pro","label":"Pro"}]Nodes in top-to-bottom stacking order within each column (2–60, unique IDs). Keep node IDs stable across updates so datasets morph smoothly; optional column fixes a node to a zero-based stage.
linksSankeyLink[]Default: [{"source":"organic","target":"activated","value":3380},{"source":"organic","target":"inactive","value":1820},{"source":"paid","target":"activated","value":1990},{"source":"paid","target":"inactive","value":1910},{"source":"activated","target":"free","value":3860},{"source":"activated","target":"pro","value":1510}]Directed acyclic flows between node IDs (up to 200). Each node is sized by the larger of its total inflow and outflow; links with value 0 are omitted from layout.
columnsstring[]—Stage names printed above each column. Hidden automatically when a header would not fit or in the upright layout below 420 px.
unitstringDefault: ""Unit appended after values in tooltips, announcements, and the data table, such as "people".
totalLabelstringDefault: "the total"Names what the first column sums to in tooltip and announcement share notes, such as "signups" for "21% of signups".
valueFormatNumberFormat—Intl number format for values in node labels, tooltips, and the table. Omit it for grouped decimals with up to one fraction digit.
heightintegerDefault: 340Plot height in pixels (200–800). Below 420 px container width the upright layout uses at least 480 px.
defaultParticlesbooleanDefault: trueInitial flowing particles state when uncontrolled. Later argument edits do not reset a mounted instance.
particleTogglebooleanDefault: trueShow the built-in Flow toggle button below the plot. Automatically hidden when motion is disabled or reduced.
emptyLabelstringDefault: "No flows yet"Shown over the plot when there are no positive links.
tableTogglebooleanDefault: falseShow a button that reveals the data table. The table is always available to assistive technology.
tableLabelstringDefault: "Data table"Name of the data table button.
localestring—BCP 47 locale for numbers and dates. Omit it to inherit the application locale (en-US by default).
recipestudio | softDefault: "studio"Visual treatment. Both recipes use the same interaction behavior.
themeSankeyFlowTheme—Color mode, accent, and semantic tokens, including the chart palette (series1–series4 tint the first four sources). See Theming.
motionnone | subtle | expressiveDefault: "subtle"Draw-in, morph, pour, and particle animation preset. System reduced-motion preferences take precedence.
motionOptionsSankeyFlowMotionOptions—draw (nodes and ribbons growing from their centers on first view; Arc's .95 s spring when omitted) and morph (flows morphing when data changes; Arc's smooth spring when omitted): a tween with a duration (ms) or a spring.
dirltr | rtl—Reading direction of headings, tooltips, and labels. Omit it to inherit the page direction.

React integration

PropPurpose
particlesControlled state of drifting particles along the ribbons
onParticlesChangeFires with the next boolean state when the Flow toggle is pressed
formatValueCustom formatter overriding valueFormat for node labels, tooltip, table
presetApplication defaults, overridden by explicit instance props
tokensCSS variables applied after the typed theme
refRef forwarded to the root <figure>
className, styleApplied to the root <figure>
Native attributesid, data-*, and remaining <figure> attributes forwarded to the root

Keyboard & accessibility

KeyInteraction
TabFocus the plot on the first node, then the Flow toggle and optional table button
ArrowUp, ArrowDownMove between nodes in the same column (ArrowLeft, ArrowRight when upright)
ArrowLeft, RightMove to the nearest node in the previous or next column (ArrowUp, Down upright)
Home, EndJump to the first node of the first or last populated column
EscapeClear the active node trace and tooltip

The chart renders a <figure> named by title (or visually hidden label when title is omitted) and linked via aria-details to a native data table listing From, To, Value, and Share of source for every positive link. SVG ribbons, node labels, and canvas particles are hidden from assistive technology.

The plot forms a single tab stop with aria-roledescription="flow diagram". Keyboard navigation highlights the focused node with a focus stroke, pours its trace, positions the tooltip beside the node, and announces the node title, value, share of totalLabel, and top connected flows politely in a live region. Headings, tooltips, footer controls, and tables follow dir="rtl", while ribbon geometry remains left to right. Under forced-colors, system colors (CanvasText, Highlight, Canvas) replace tinted fills and shadows.

Motion and theming

When 30% of the chart enters the viewport, nodes and ribbons expand from their centers on a 950 ms zero-bounce spring (motionOptions.draw); server-rendered markup is final. Data updates morph node positions and ribbon widths in place on a smooth spring (motionOptions.morph), while container resizes snap immediately. Hover and focus pour the traced share along ribbons on a smooth spring and glide the tooltip on a snappy spring.

Optional particles drift at 46 px/s on a DPR-scaled canvas capped at 34 grains per ribbon, fading at ribbon ends and pausing automatically when scrolled off screen or in a background tab. Both motion="none" and prefers-reduced-motion: reduce jump layout and trace updates immediately (0 ms), disable particles, and hide the Flow toggle.

theme accepts a mode, an accent, and semantic tokens across the core, control, and chart token groups (series1–series4 tint the first four sources). An application-wide UtherealProvider supplies defaults.

Composition

In an agent composition, SankeyFlow is a leaf with no actions. onParticlesChange is a transient UI control bound to particles. The host updates nodes and links through composition updates. See Building with agents.

{
  "type": "SankeyFlow",
  "props": {
    "label": "Signup journey",
    "columns": ["Source", "Activation", "Plan"],
    "unit": "people",
    "totalLabel": "signups",
    "nodes": [
      { "id": "organic", "label": "Organic" },
      { "id": "paid", "label": "Paid" },
      { "id": "activated", "label": "Activated" },
      { "id": "pro", "label": "Pro" }
    ],
    "links": [
      { "source": "organic", "target": "activated", "value": 3380 },
      { "source": "paid", "target": "activated", "value": 1990 },
      { "source": "activated", "target": "pro", "value": 1510 }
    ]
  },
  "children": []
}

On this page