ui-kit0.0

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.

Donut chart: Organic search 4,820, Direct 3,160, Referral 1,940, Social 1,280, Email 760.
sourcevisitorsShare
Organic search4,82040.3%
Direct3,16026.4%
Referral1,94016.2%
Social1,28010.7%
Email7606.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.

Pie chart: Starter 612, Team 348, Enterprise 74.
planaccountsShare
Starter61259.2%
Team34833.7%
Enterprise747.2%

API

DonutChart

PropTypeDefaultDescription
dataRecord<string, unknown>[]—One record per slice. Names must be unique.
indexstring—Key of the slice name.
valueKeystring—Key of the slice value. Zero and negative values are skipped.
colorsSeriesColor[]—Colour per slice; defaults to series-1…6 in order.
innerRadiusnumber0.62Hole size as a fraction of the radius. 0 is a pie.
padAnglenumber2Gap between slices, in degrees.
cornerRadiusnumber4Rounded slice corners in px (shrinks on thin slices).
centerLabel / centerValueReactNode—Override the hole text. Defaults to the hovered slice, or "Total".
heightnumber240Diameter limit in px.
valueFormatValueFormat'number'Formats values in the hole and tooltip.
legend'top' | 'bottom' | false'bottom'Clicking an item hides that slice.
tooltip / animatebooleantrueTooltip shows value and share; animate sweeps the ring on mount.

Keyboard

KeyAction
TabFocuses the chart.
← / →Moves to the previous or next slice.
Home / EndFirst or last slice.
EscClears 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.