Skip to content

Chord Diagram for React

A React chord diagram draws flows between a handful of groups as ribbons across a circle. Pass groups plus a square matrix: matrix[i][j] is the flow from group i to group j.

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

Plan changes, quarter on quarter

Use the arrow keys to read it: left and right move around the groups, down steps through a group's ribbons, right and left on a ribbon jump between its two ends.

  • ChordDiagram
  • ChordTable
  • chordLegend
  • defaultChordTableLabels
  • defaultChordDiagramLabels
  • +3 more

Plan changes, quarter on quarter

Accounts that moved between plans. Hover a plan to light up its ribbons; hover a ribbon to read both directions. Switch the quarter: every arc and ribbon tweens to its new angle. With the keyboard, left and right go around the plans, down steps through a plan's ribbons.

Plan changes

Accounts that changed plan in Q3

3.9Kaccounts moved
Use the arrow keys to read it: left and right move around the groups, down steps through a group's ribbons, right and left on a ribbon jump between its two ends.
  • Free
  • Starter
  • Pro
  • Team
  • Enterprise

Code review across teams, names in the legend

showLabels={false} leaves the names to the ChartCard legend (chordLegend), so the circle gets all the room. With the default showLabels, names that would not fit around the ring (a phone, a crowded side) move into a legend under the circle by themselves.

Who reviews whom

Pull request reviews, last 90 days

  • Web
  • Mobile
  • Platform
  • Data
  • Design system
  • Infrastructure
Use the arrow keys to read it: left and right move around the groups, down steps through a group's ribbons, right and left on a ribbon jump between its two ends.

Files to copy

13 folders · 29 files · 4 packages
From theme/src/
  • components/charts/{chord-diagram.tsx, chart-export-menu.tsx, chart-export.ts, chart-figure.tsx, chart-fit.tsx, chart-icons.tsx, chart-parts.tsx, chart-patterns.tsx, chart-tip.tsx, chart-utils.ts, flow-utils.tsx, heatmap.tsx}
  • components/charts/chart-parts/
  • components/charts/chord-diagram/
  • components/charts/heatmap/
  • components/drawer/parts/sheet.tsx
  • components/kbd/
  • components/menu/
  • components/skeleton/
  • components/status-icons/
  • hooks/{use-controllable.ts, use-intersection.ts, use-latest.ts, use-media-query.ts, use-preferences.ts, use-resolved-scheme.ts}
  • motion/tokens.ts
  • lib/{cn.ts, csv.ts, form.ts, glide-highlight.tsx, heading.ts, math.ts, popup-a11y.ts, popup-motion.ts, warn-once.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/chord-diagram.jsonRegistry item: chord-diagram. 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".

Props

PropTypeDefaultDescription
groups (required)readonly ChordGroup[]NoneThe groups around the circle, in order (≤ 8; the rest fold into "Other").
matrix (required)readonly (readonly number[])[]Nonematrix[i][j]: the flow from group i to group j (the ribbon's width at i). Missing and negative values read as 0.
heightnumber360Height in px; the circle fits the smaller of width and height.
padAnglenumber0.04Gap between groups, in radians.
showLabelsbooleantruePrint each group's name outside the ring where it fits; names that don't fit are listed in a legend under the circle.
format((n: number) => string)compact numbers in localeFormats a flow value for the labels, tooltips and data table: takes the number, returns the text shown.
formatPercent((ratio: number) => string)percentages in localeFormats a share of the total for the tooltips and data table: takes the share, returns the text shown.
localestring"en"Locale of the default number formats.
onGroupClick((group: { id: string; label: string; outflow: number; inflow: number; }) => void)NoneCalled with { id, label, outflow, inflow } when a group is clicked, tapped, or activated with Enter. Makes groups interactive.
emptyStateReactNodeNoneShown when there is nothing to plot.
labelsPartial<ChordDiagramLabels>defaultChordDiagramLabelsEvery other string, for translation: labels={{ roleDescription: "…" }}; omitted keys keep the English of defaultChordDiagramLabels. All 10 keys of ChordDiagramLabels are listed in the key table under the props table.
aria-label (required)stringNoneNames the chart for assistive tech (required).
classNamestringNoneAdds extra classes to the outer element.
ChordDiagramLabels keys and English defaults (10)
Pass any key in labels; the rest keep the defaults of defaultChordDiagramLabels.
KeyEnglish default
roleDescriptionchord diagram
instructionsUse the arrow keys to read it: left and right move around the groups, down steps through a group's ribbons, right and left on a ribbon jump between its two ends.
hintTap a group or a ribbon to read it
otherOther
outflowout
inflowin
ofTotalof all flow
ribbonTitle(a, b) => `${a} and ${b}`
direction(from, to) => `${from} → ${to}`
ribbonCount(count) => `${count} ${count === 1 ? "ribbon" : "ribbons"}`

ChordTable props

PropTypeDefaultDescription
format((n: number) => string)compact numbers in localeFormats a flow value for the labels, tooltips and data table: takes the number, returns the text shown.
localestring"en"Locale of the default number formats.
groups (required)readonly ChordGroup[]NoneThe groups around the circle, in order (≤ 8; the rest fold into "Other").
matrix (required)readonly (readonly number[])[]Nonematrix[i][j]: the flow from group i to group j (the ribbon's width at i). Missing and negative values read as 0.
captionstringNoneHidden caption that names the table for screen readers.
labelsPartial<ChordTableLabels>defaultChordTableLabelsColumn headers. Merged over defaultChordTableLabels. Every other string, for translation: labels={{ corner: "…" }}; omitted keys keep the English of defaultChordTableLabels. All 3 keys of ChordTableLabels are listed in the key table under the props table.
emptyStateReactNodeNoneShown when there are no rows.
ChordTableLabels keys and English defaults (3)
Pass any key in labels; the rest keep the defaults of defaultChordTableLabels.
KeyEnglish default
cornerFrom \ To
totalTotal out
otherOther

Keyboard

KeysAction
TabFocus the diagram (one stop).
←/→Previous / next group around the circle; on a ribbon, back to its group / on to its other end.
↓/↑Step through the active group's ribbons, largest first (↑ from the first ribbon returns to the group; ↑ on a group goes round to its last ribbon).
Home/EndFirst / last group.
Enter/SpaceCall onGroupClick for the active group.
EscapeFrom a ribbon back to its group; then clear the reading.

Accessibility

  • The diagram is one focusable figure with the role description “chord diagram”; keys never scroll the page while it has focus.
  • A group is announced with its outflow, inflow and share (“Pro: 1,185 out, 1,235 in, 30% of all flow. 5 ribbons”); a ribbon reads both directions.
  • Names that don't fit around the ring move into a legend under it by themselves; the Table view (ChordTable) is the full matrix.
  • On the light theme, crowded diagrams (more than 5 groups) blend ribbons normally at a lower opacity, so crossings stay clean and readable.
  • Reduced motion: the ring and ribbons appear at once and data changes jump.

All exports on this page

  • ChordDiagram — Flows between a handful of groups (≤ 8) as ribbons across a circle: who hands work to whom, plan upgrades and downgrades, trade between regions.
  • ChordTable — The flow matrix as a table: one row per source group, one column per target, plus row totals.
  • chordLegend — Legend items for a chord diagram (pass to ChartCard's legend, useful when names don't fit outside the ring).
  • defaultChordDiagramLabels — The built-in English strings of ChordDiagram; spread it into your own labels and change what you need.
  • defaultChordTableLabels — English defaults of ChordTableLabels.

When to use the chord diagram

  • Use it as a chord chart for flows between a handful of groups that go both ways: who hands tickets to whom across support tiers, plan upgrades and downgrades, or trade between regions.
  • Use it to show migration between segments, such as customers moving among free, pro and enterprise plans, where each ribbon's width at an end is the flow leaving that group.
  • Make groups clickable with onGroupClick, which receives the id, label, outflow and inflow, so a click can open a drill-down for that team or region.
  • Skip it when flows run one way from sources to targets or you have more than eight groups, because a Sankey chart handles directed stages and the Chord folds the extras into Other.
  • Pair it with ChartCard and ChordTable, which gives the whole flow matrix as text, and with a Select to switch the period the matrix covers.

Frequently asked questions

48 charts pages in all: browse them on Charts.

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