Charts
Donut & pie
Parts of a whole.
Usage
DonutChart shows parts of a whole. The hole shows the total, or the value of the hovered slice. Slices have a small gap and rounded corners; hovering pushes one slice outward.
| source | visitors | Share |
|---|---|---|
| Organic search | 4,820 | 40.3% |
| Direct | 3,160 | 26.4% |
| Referral | 1,940 | 16.2% |
| Social | 1,280 | 10.7% |
| 760 | 6.4% |
When to use
- Five or fewer parts that add up to a meaningful total.
- A quick read of the biggest share.
Not for: comparing many close values (use bars) or showing change over time.
Pie
Set innerRadius={0} for a pie. Pass colors to choose a colour per slice.
| plan | accounts | Share |
|---|---|---|
| Starter | 612 | 59.2% |
| Team | 348 | 33.7% |
| Enterprise | 74 | 7.2% |
API
DonutChart
| Prop | Type | Default | Description |
|---|---|---|---|
| data | Record<string, unknown>[] | — | One record per slice. Names must be unique. |
| index | string | — | Key of the slice name. |
| valueKey | string | — | Key of the slice value. Zero and negative values are skipped. |
| colors | SeriesColor[] | — | Colour per slice; defaults to series-1…6 in order. |
| innerRadius | number | 0.62 | Hole size as a fraction of the radius. 0 is a pie. |
| padAngle | number | 2 | Gap between slices, in degrees. |
| cornerRadius | number | 4 | Rounded slice corners in px (shrinks on thin slices). |
| centerLabel / centerValue | ReactNode | — | Override the hole text. Defaults to the hovered slice, or "Total". |
| height | number | 240 | Diameter limit in px. |
| valueFormat | ValueFormat | 'number' | Formats values in the hole and tooltip. |
| legend | 'top' | 'bottom' | false | 'bottom' | Clicking an item hides that slice. |
| tooltip / animate | boolean | true | Tooltip shows value and share; animate sweeps the ring on mount. |
Keyboard
| Key | Action |
|---|---|
| Tab | Focuses the chart. |
| ← / → | Moves to the previous or next slice. |
| Home / End | First or last slice. |
| Esc | Clears the selection. |
Accessibility
- role="img" with a label listing every slice and value, plus a hidden table with the share of each.
- The active slice is announced through a polite live region.
- The legend names every slice, so colour is not the only cue.
Motion
- The ring sweeps clockwise on mount (700ms, ease-out).
- A hovered slice moves 6px outward; the rest fade slightly.
- Reduced motion: drawn at full size straight away.