# Chord diagram

> Flows between groups as ribbons around a ring: hover a group to isolate its chords, switch periods and every arc and ribbon morphs.

- Type: Component (data)
- Access: Arc Pro
- Page: https://uiarc.dev/components/chord-diagram
- Markdown: https://uiarc.dev/components/chord-diagram/markdown
- Source file: `registry/components/chord-diagram/chord-diagram.tsx`
- Dependencies: motion
- Keywords: data, chart, new, chord diagram, chord chart, flows, matrix, ribbons, circular, handoffs, trade flows

## When to use

- Showing who exchanges the most with whom in both directions.
- Comparing flow patterns between two periods.

## When not to use

- Use sankey-flow for flows through ordered stages.
- Use network-graph when there are many nodes with sparse links.

## Installation

Chord diagram is part of Arc Pro. The live preview is public; the source and install command need Pro.

### CLI with a Pro token

1. Create a token in your account and set it in the environment (or `.env.local`). Never commit it.

```bash
export ARC_PRO_TOKEN=arc_pro_...
```

2. Add the Pro registry to `components.json`:

```json
{
  "registries": {
    "@uiarc": "https://uiarc.dev/r/{name}.json",
    "@uiarc-pro": {
      "url": "https://uiarc.dev/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${ARC_PRO_TOKEN}"
      }
    }
  }
}
```

3. Install:

```bash
npx shadcn@latest add @uiarc-pro/chord-diagram
```

### Manual

Signed-in Pro members can copy the source from the Manual tab on the docs page.

- Plans: https://uiarc.dev/pricing
- Create a Pro token: https://uiarc.dev/account#pro-access
- Setup guide: https://uiarc.dev/docs/ai#pro-access

## Usage

```tsx
import { ChordDiagram } from "@/components/arc/chord-diagram/chord-diagram";

const groups = [{ id: "design", label: "Design" }, { id: "eng", label: "Engineering" }, { id: "qa", label: "QA" }];
const matrix = [
  [0, 118, 6],
  [38, 0, 142],
  [4, 126, 0],
];

export function Handoffs() {
  return <ChordDiagram groups={groups} matrix={matrix} label="Handoffs between teams" />;
}
```

## API reference

### ChordDiagram

Flows between groups as ribbons around a ring. Hover or focus a group to isolate its chords, read both directions of any ribbon, and switch datasets to morph every arc and ribbon.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `groups` (required) | `{ id: string; label: string; category?: string }[]` | – | The groups around the ring, in order. A stable id keeps each arc across datasets. |
| `matrix` (required) | `number[][]` | – | Square matrix of flows: matrix[i][j] is the flow from groups[i] to groups[j]. The diagonal is ignored. |
| `label` (required) | `string` | – | What flows. Names the chart for assistive technology. |
| `categories` | `{ id: string; label: string }[]` | – | Names and order of the categories. The first four take the series hues and a legend names them. |
| `formatValue` | `(value: number) => string` | – | Formats flows and totals. |
| `size` | `number` | `380` | Largest diameter in pixels. The ring is redrawn at the rendered size on narrow screens. |
| `active` | `string \| null` | – | Controlled id of the isolated group. |
| `defaultActive` | `string \| null` | `null` | Initial isolated group when uncontrolled. |
| `onActiveChange` | `(id: string \| null) => void` | – | Called when a group is isolated or released. |
| `legend` | `boolean` | `true` | Shows groups with what each sends. Rows isolate on hover, focus, and click. |
| `emptyLabel` | `string` | `"No flows yet"` | Shown when every flow is zero. |
| `className` | `string` | – | Extra class on the root figure. |

## Keyboard interactions

| Keys | Action |
| --- | --- |
| ArrowLeft / ArrowRight | Moves between groups and isolates the one in focus. |
| ArrowDown / ArrowUp | Walks the focused group's ribbons, largest first. |
| Enter / Space | Keeps the focused group isolated, or releases it. |
| Escape | Steps back from a ribbon to its group, then clears isolation. |

## Accessibility

- The ring is a focusable group with a description of its keys; legend rows are buttons with aria-pressed for isolation.
- Groups and ribbons are announced with both directions of flow through a polite live region.
- A visually hidden matrix table lists every flow from row to column.

## Motion

- Arcs and ribbons interpolate their angles on one spring, so a new dataset swells and shifts every flow in place.
- The first reveal draws the ring, then pours the ribbons in a beat later.
- Isolation fades other ribbons and deepens the chosen ones; the tooltip glides and stays inside the ring.
- Reduced motion places the final geometry immediately.

## Responsive behavior

- The ring redraws at its rendered size so labels keep their type size; labels hide on arcs too short to hold them, and the legend carries them.
- The legend wraps beside or under the ring and becomes a two-column grid on narrow widths.

## Performance

- One path per group pair; geometry is painted imperatively during springs. Comfortable up to about 12 groups.

## Notes for AI

- Choose it for two-way flows among 4 to 10 groups: team handoffs, trade, migration, or referrals.
- Arcs are sized by what each group sends; the tooltip shows what it receives.
- Use categories to color families of groups instead of giving every group its own hue.
- Colors come from the shared --series-1 to --series-4 tokens in foundation.css: series 1 is the accent itself and series 2 to 4 rotate its hue, validated all-pairs for color vision deficiency across every accent in light and dark. Override the tokens on any ancestor to rebrand.

## Related

- [Sankey flow](https://uiarc.dev/components/sankey-flow/markdown): Flows between stages as ribbons with drifting particles; hover any node or ribbon to pour its share through the whole journey.
- [Sunburst](https://uiarc.dev/components/sunburst/markdown): A hierarchy in rings: click a segment and every arc swings around it as the new centre, with a breadcrumb back and a rolling total.
- [Donut chart](https://uiarc.dev/components/donut-chart/markdown): A donut whose arcs morph between datasets, with the active value rolling into the center.

## Also in advanced charts

- [Beeswarm](https://uiarc.dev/components/beeswarm/markdown): Every item as a dot, packed without overlap, that flows to its new place when the metric or rows change, with a brush to select a range.
- [Funnel chart](https://uiarc.dev/components/funnel-chart/markdown): A tapered conversion funnel with drop-off at every step, a device split that morphs the band, and dots that stream through it.
- [Radar chart](https://uiarc.dev/components/radar-chart/markdown): Two or three profiles on one web: shapes morph when you swap a profile, and a sweep across the axes compares values in place.
- [Realtime stream](https://uiarc.dev/components/realtime-stream/markdown): A live line that scrolls at 60fps as readings arrive, holds still on hover to read, and pops a marker on every anomaly.
- [Race bar chart](https://uiarc.dev/components/race-bar-chart/markdown): A ranking over time: bars overtake each other on springs, values count up, and a timeline you can play or scrub.
- [Data grid](https://uiarc.dev/components/data-grid/markdown): A spreadsheet grid with range selection, inline editing, a fill handle, and animated sorting.

## Guidance for AI tools

Chord diagram: Flows between groups as ribbons around a ring: hover a group to isolate its chords, switch periods and every arc and ribbon morphs. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://uiarc.dev/llms.txt
