Flow

Flow primitives for Sankey-style diagrams: a FlowChart that lays out nodes in columns with link bands, hover highlighting and a readout, plus FlowPathSteps that renders a step sequence as chips. The module also exports the layout helpers (layoutFlow, getFlowPath, getFlowTotals) and flowPalette.

Flow
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

pnpm dlx shadcn@latest add @dashboardblocks/flow

Requires @dashboardblocks in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { FlowChart } from '@/components/dashboardblocks/flow'export function Example() {  return (    <FlowChart      nodes={[        { id: 'visit', label: 'Visit', column: 0 },        { id: 'signup', label: 'Sign up', column: 1 },        { id: 'drop', label: 'Dropped', column: 1, kind: 'exit' },      ]}      links={[        { source: 'visit', target: 'signup', value: 620 },        { source: 'visit', target: 'drop', value: 380 },      ]}    />  )}
  • Showing how a quantity (users, revenue, traffic) splits and flows across ordered stages, such as a funnel with drop-offs or a conversion breakdown.
  • Building an interactive Sankey chart in a dashboard card where hovering a link or node should reveal exact values and percentages.
  • Displaying a compact, ordered sequence of page or step names in a card, for example a user journey or checkout path.
  • Needing a pure layout function (layoutFlow) to compute node and link geometry for a custom renderer.

Examples

Conversion funnel with default readout

A three-stage funnel with an exit node. Idle state shows the children caption; hovering a band or node replaces it with the default readout text.

conversion-funnel-with-default-readout.tsx
import { FlowChart } from '@/components/dashboardblocks/flow'export function SignupFlow() {  return (    <FlowChart      nodes={[        { id: 'visit', label: 'Visit', column: 0 },        { id: 'signup', label: 'Sign up', column: 1 },        { id: 'paid', label: 'Paid', column: 2 },        { id: 'drop', label: 'Dropped', column: 1, kind: 'exit' },      ]}      links={[        { source: 'visit', target: 'signup', value: 620 },        { source: 'visit', target: 'drop', value: 380 },        { source: 'signup', target: 'paid', value: 210 },      ]}      format={(value) => value.toLocaleString()}    >      Hover a band to see conversion.    </FlowChart>  )}

Narrow card with horizontal scroll and custom readout

Sets minWidth so the chart scrolls sideways inside a labelled, focusable region on narrow cards, and supplies a custom describeLink string.

narrow-card-with-horizontal-scroll-and-custom-readout.tsx
import { FlowChart } from '@/components/dashboardblocks/flow'export function TrafficFlow() {  return (    <FlowChart      label='Traffic sources to purchases'      minWidth='480px'      height={320}      colorBy='target'      nodes={[        { id: 'search', label: 'Search', column: 0 },        { id: 'social', label: 'Social', column: 0 },        { id: 'landing', label: 'Landing', column: 1 },        { id: 'buy', label: 'Purchase', column: 2 },      ]}      links={[        { source: 'search', target: 'landing', value: 900 },        { source: 'social', target: 'landing', value: 450 },        { source: 'landing', target: 'buy', value: 300 },      ]}      describeLink={(link, source, target) =>        `${source.label} to ${target.label}: ${link.value}`      }    />  )}

Path steps as chips

Renders an ordered journey as a wrapped row of step chips with arrow separators.

path-steps-as-chips.tsx
import { FlowPathSteps } from '@/components/dashboardblocks/flow'export function JourneyPath() {  return (    <FlowPathSteps      steps={[        { label: 'Home' },        { label: 'Pricing' },        { label: 'Checkout' },        { label: 'Thank you' },      ]}    />  )}

API reference

PropTypeDefaultDescription
nodesFlowNode[]—Nodes to draw. Each has id, label, optional column (0-based stage index; otherwise inferred from links), optional color, and optional kind 'default' | 'exit' (exit nodes and their incoming links are drawn in muted-foreground).
linksFlowLink[]—Directed links between node ids. Each has source, target and a numeric value that sets band thickness.
classNamestringundefinedExtra classes merged onto the outer flex column wrapper.
colorBy'source' | 'target''source'Which node's colour the link bands use. With 'source', nodes without an explicit colour inherit their largest incoming source's colour.
describeLink(link: FlowLink, source: FlowLayoutNode, target: FlowLayoutNode) => stringundefinedBuilds the readout text shown while a link is hovered or pressed. Falls back to 'Source → Target: value (share% of Source)'.
describeNode(node: FlowLayoutNode) => stringundefinedBuilds the readout text shown while a node is hovered or pressed. Falls back to 'Label: formatted value'.
format(value: number) => string(value) => value.toLocaleString()Formats values in labels and readouts.
heightnumber280Height of the chart in pixels.
labelstring'Flow'Accessible name of the scrolling region. Only applied when minWidth is set.
minWidthstringundefinedMinimum chart width (CSS length). Below this the chart scrolls horizontally inside a focusable region.
childrenReactNodeundefinedCaption shown beneath the chart while nothing is active; replaced by the readout on hover or press.

Accessibility

  • When minWidth is set, the scroll container gets role='region', aria-label from the label prop, and tabIndex 0 with a visible focus ring so keyboard users can reach columns that do not fit.
  • The SVG diagram itself is aria-hidden; the chart's meaning should be conveyed by the children caption or surrounding text, and the readout paragraph updates with the hovered or pressed item.
  • Interaction is pointer-driven (pointer enter and pointer down). Nodes and links are not individually focusable, so provide the key figures in text or a table alongside the chart for keyboard and screen-reader users.
  • FlowPathSteps is an ordered list (ol/li) so the sequence is announced in order; the arrow separators are aria-hidden.
  • Colour is not the only cue: labels and values are drawn beside every node, and exit nodes are also identified by their 'Dropped'-style label.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Flow" component (dashboardblocks/flow) from its shadcn registry.1. Install it with: npx shadcn@latest add @dashboardblocks/flow2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: nodes, links, className, colorBy, describeLink, describeNode, format, height, label, minWidth, children.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { FlowChart } from '@/components/dashboardblocks/flow'export function Example() {  return (    <FlowChart      nodes={[        { id: 'visit', label: 'Visit', column: 0 },        { id: 'signup', label: 'Sign up', column: 1 },        { id: 'drop', label: 'Dropped', column: 1, kind: 'exit' },      ]}      links={[        { source: 'visit', target: 'signup', value: 620 },        { source: 'visit', target: 'drop', value: 380 },      ]}    />  )}```

Files & dependencies

  • registry/components/dashboardblocks/flow.tsx→ @components/dashboardblocks/flow.tsx
dependenciesrecharts
registryDependencieshttps://www.dashboardblocks.com/r/radix/chart.jsonhttps://www.dashboardblocks.com/r/radix/format.json

Looks similar, elsewhere