Skip to content

Streamgraph for React

A React streamgraph shows how a mix swells and fades over time as stacked areas flowing around a moving center line. Pass data as readonly ChartRow[]: one row per x value.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/streamgraph.json

Listening by genre

Use left and right arrow keys to move through time, up and down to pick a layer.

  • Streamgraph
  • StreamgraphTable
  • insideOutOrder
  • streamBaseline
  • foldStreamSeries
  • +5 more
  • +2 more

A year of listening

Seven genres over 52 weeks. Hover a layer to bring it forward; use left / right to move through time and up / down to pick a layer. Switch the baseline to compare wiggle and silhouette.

Listening by genre

Hours per week, Nov 2025 to Oct 2026, by genre

  • Pop
  • Hip-hop
  • Rock
  • Electronic
  • Jazz
  • Classical
  • Lo-fi

Files to copy

16 folders · 33 files · 4 packages
From theme/src/
  • components/charts/{streamgraph.tsx, category-bar.tsx, chart-export-menu.tsx, chart-export.ts, chart-figure.tsx, chart-fit.tsx, chart-icons.tsx, chart-parts.tsx, chart-patterns.tsx, chart-pointer.tsx, chart-tip.tsx, chart-utils.ts, heatmap.tsx}
  • components/button/
  • components/charts/category-bar/
  • components/charts/chart-parts/
  • components/charts/heatmap/
  • components/charts/streamgraph/
  • components/drawer/parts/sheet.tsx
  • components/kbd/
  • components/menu/
  • components/skeleton/
  • components/spinner/
  • components/status-icons/
  • hooks/{use-controllable.ts, use-direction.ts, use-intersection.ts, use-latest.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts}
  • motion/{gate.ts, tokens.ts}
  • lib/{cn.ts, csv.ts, form.ts, glide-highlight.tsx, heading.ts, math.ts, popup-a11y.ts, popup-motion.ts, state-light.tsx, warn-once.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/streamgraph.jsonRegistry item: streamgraph. The styles need the Tailwind v4 glass UI setup.
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Next.js: samples here pass functions (formatters, seriesLegend, a dashboard's load), so put them in a file that starts with "use client".

Traffic sources around a launch

Thirty days of visits by source, with a launch spike in week three. Silhouette or wiggle, the total is always the stream's thickness.

Visits by source

Last 30 days

  • Search
  • Direct
  • Social
  • Referral
  • Email

Props

PropTypeDefaultDescription
data (required)readonly ChartRow[]NoneOne row per x value (e.g. per week).
index (required)stringNoneKey of the x value in each row.
series (required)readonly ChartSeries[]NoneThe layers. Up to 8 keep their colour slot; any more fold into “Other”.
offset"wiggle" | "silhouette""wiggle""wiggle" (default): the classic streamgraph, as flat as possible. "silhouette": mirrored around a centre line.
order"none" | "insideOut""insideOut""insideOut" (default) puts layers that peak mid-way in the middle; "none" keeps series order (bottom up).
inlineLabelsbooleantrueName each layer inside its thickest stretch, when it fits.
heightnumber300Height of the chart in px; the width follows the container.
format((n: number) => string)formatCompact in localeFormats a value for the tooltips and data table: takes the number, returns the text shown.
formatPercent((ratio: number) => string)percentages in localeFormats shares of the total.
localestring"en"Locale of the default number formats.
emptyStateReactNodeNoneShown when there is nothing to plot.
patternsbooleantrue when layers > 3Tell layers apart without colour (hatch fills; the first layer stays solid).
labelsPartial<StreamgraphLabels>defaultStreamgraphLabelsEvery other string, for translation: labels={{ instructions: "…" }}; omitted keys keep the English of defaultStreamgraphLabels. All 5 keys of StreamgraphLabels are listed in the key table under the props table.
aria-label (required)stringNoneAccessible summary of what the chart shows.
classNamestringNoneAdds extra classes to the outer element.
StreamgraphLabels keys and English defaults (5)
Pass any key in labels; the rest keep the defaults of defaultStreamgraphLabels.
KeyEnglish default
instructionsUse left and right arrow keys to move through time, up and down to pick a layer.
totalTotal
otherOther
touchHintTap or drag across the chart to read values
emptyNo data

StreamgraphTable props

PropTypeDefaultDescription
data (required)readonly ChartRow[]NoneOne row per x value (e.g. per week).
format((n: number) => string)formatCompact in localeFormats a value for the tooltips and data table: takes the number, returns the text shown.
labelsPartial<StreamgraphLabels>defaultStreamgraphLabelsEvery other string, for translation: labels={{ instructions: "…" }}; omitted keys keep the English of defaultStreamgraphLabels. All 5 keys of StreamgraphLabels are listed in the key table under the props table.
localestring"en"Locale of the default number formats.
index (required)stringNoneKey of the x value in each row.
series (required)readonly ChartSeries[]NoneThe layers. Up to 8 keep their colour slot; any more fold into “Other”.
indexLabelstringNoneSets the header of the first column.
captionstringNoneHidden caption that names the table for screen readers.

Keyboard

KeysAction
TabFocus the chart (one tab stop).
←/→Move through time.
↑/↓Pick a layer, top to bottom as stacked on screen.
Home/EndFirst / last point in time.
EscapeClear the layer and the crosshair.

Accessibility

  • The chart is one focusable figure; each step through time announces every layer's value and share, largest first, then the total. With a layer picked, only that layer is read.
  • Layer names sit on solid tags of the chart surface, so they meet AA contrast on any layer color; layers that are too thin for a name rely on the legend and the tooltip.
  • Color slots are fixed per series and never repeat: more than 8 layers fold into a gray “Other”.
  • On phones the readout docks above the plot instead of covering it; vertical swipes keep scrolling the page.
  • The table view lists every value with a total column. Reduced motion draws the layers in place.

All exports on this page

  • Streamgraph — Stacked areas flowing around a moving centre line: how a mix of categories swells and fades over time (genres, topics, traffic sources).
  • StreamgraphTable — One row per x value, one column per layer, plus the total.
  • defaultStreamgraphLabels — The built-in English strings of Streamgraph; spread it into your own labels and change what you need.
  • foldStreamSeries — Fold series past the 8th into one "Other" layer (neutral grey).
  • insideOutOrder — Inside-out order (Byron & Wattenberg): series that peak early and late go to the edges, the ones peaking mid-way sit in the middle.
  • streamBaseline — Baseline per x of a stream: "wiggle" minimises the layers' weighted slope (Byron & Wattenberg's streamgraph, as d3's stackOffsetWiggle).
  • streamgraphLegend — Legend for a streamgraph: one swatch per layer, as folded.

When to use Streamgraph

  • Use it as a stream chart for a year of listening hours by genre, where the shape of each layer shows how a mix swells and fades across 52 weeks.
  • It suits traffic sources around a launch, with thirty days of visits by source and a spike in week three, where the stream's thickness is always the total.
  • It works for any many-category time series where totals matter less than the rhythm of change, with layer names printed inside their thickest stretch when they fit.
  • Skip it when readers must read exact values or compare layers against a common baseline; StackedAreaChart keeps a flat bottom, and LineChart compares individual series better.
  • Pair it with ChartCard and its legend, StreamgraphTable for exact values as text, and a SegmentedControl to switch offset between wiggle and silhouette.

Frequently asked questions

48 charts pages in all: browse them on Charts.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .