Quire UI
Charts10

Donut

One whole and its parts as a ring, with the total in the middle and a legend of every amount and share. The smallest fold into Other. No chart library.

Visitors by device, October
Desktop48,21051%
Mobile39,87042%
Tablet6,1406.5%

Installation

npx shadcn@latest add @quireui/donut

Usage

<Donut
  label="Visitors by device"
  items={[
    { name: "Desktop", value: 48210 },
    { name: "Mobile", value: 39870 },
    { name: "Tablet", value: 6140 },
  ]}
/>

The parts are drawn largest first, from the top, clockwise, with a hairline of the surface between them. The total sits in the middle; point at a slice, or arrow to it, and the middle reads that part instead. Each part keeps the colour of its place in items, so hiding one never repaints the rest.

Angles are hard to compare by eye, so the legend lists every part with its exact amount and share. Close parts are told apart there, not in the ring. Click a part in the legend to hide it; the ring and the total close up around the rest.

The smallest parts

A ring with a dozen slivers says nothing, so parts under 3% of the whole fold into Other, and so does everything past the sixth slice. group and max change those. Other is a quiet grey, never a chart colour. The legend names what it holds, like "Other · Samsung Internet, Opera +2", and so does the middle while Other is read; screen readers hear every name.

Visitors by browser
Chrome51,20055%
Safari24,80027%
Edge7,3007.8%
Firefox5,9006.3%
Samsung Internet1,8001.9%
Opera9001%
Arc7000.8%
Brave5000.5%

Against the period before

Give each part its previous amount and its share says how it moved, in percentage points, in the legend and in the middle: Mobile went from 36% to 42%, "↗ 5.9 pt". Points, because a share going from 36% to 42% is six points, not "16% more". The example at the top compares with the month before.

Choosing a part

onPick is called with a part's name when its slice is clicked or chosen with Enter, like to filter the page by it. active and onActiveChange share the part being read with anything beside the donut. center replaces the middle with your own content, given the part being read, its share and the total.

hidden and onHiddenChange do the same for the parts the legend hides, so a filter elsewhere on the page can hide and show them too. Other is named by its label.

Accounts by plan
Free1,84069%
Pro61223%
Team1887.1%
Enterprise240.9%

Click a slice, or press Enter on one, to filter by its plan.

Loading and empty

Visitors by device

Accessibility

The ring is a slider over the parts, so it works without a pointer, which most donuts leave to their legend. Screen readers hear its name and total, then each part as you move, like "Mobile: 39,870, 42%, Up 5.9 pt". The legend's parts are toggle buttons that say whether a part is shown; hiding or showing one is read out with the new total, like "Desktop hidden. Total 46,010". Every part, Other's members included, is in a table read with the ring.

KeyAction
← / →, ↑ / ↓Previous or next part, round the ring
Home / EndFirst or last part
EnterWith onPick: chooses the part
EscBack to the total

Motion

Small and once. When the donut first scrolls into view, the ring grows in from a touch smaller, then the middle and the legend follow, all within a quarter of a second; a donut already on screen when the page loads stays put, and new data never replays it. The slice being read moves out a few pixels while the others step back, eased. When new numbers arrive, the slices glide to their new sizes and the total's changed digits slide in the way they moved; a part hidden from the legend shrinks away while the rest close up. Try the month switch above. From the keyboard nothing waits, and with reduced motion only the fades remain. animate={false} turns the gliding and the digits off.

Donut or something else?

  • Comparing the parts, ranking them, or more than six: a Bar list. Bars on one baseline compare more exactly than angles.
  • How one whole splits, in a card or a table row: a Meter stack.
  • One amount against a limit, like storage used: a Meter.

API reference

Donut

One whole and its parts, as a ring with the total in the middle. The legend lists every part with its amount and share, so close ones can still be told apart; the smallest fold into Other.

Prop

Type

Also takes every <figure> attribute. Style it with [data-slot="donut-change"].

On this page