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.
| Desktop | 48,210 | 51% |
|---|---|---|
| Mobile | 39,870 | 42% |
| Tablet | 6,140 | 6.5% |
Installation
npx shadcn@latest add @quireui/donutUsage
<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.
| Chrome | 51,200 | 55% |
|---|---|---|
| Safari | 24,800 | 27% |
| Edge | 7,300 | 7.8% |
| Firefox | 5,900 | 6.3% |
| Samsung Internet | 1,800 | 1.9% |
| Opera | 900 | 1% |
| Arc | 700 | 0.8% |
| Brave | 500 | 0.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.
| Free | 1,840 | 69% |
|---|---|---|
| Pro | 612 | 23% |
| Team | 188 | 7.1% |
| Enterprise | 24 | 0.9% |
Click a slice, or press Enter on one, to filter by its plan.
Loading and empty
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.
| Key | Action |
|---|---|
| ← / →, ↑ / ↓ | Previous or next part, round the ring |
| Home / End | First or last part |
| Enter | With onPick: chooses the part |
| Esc | Back 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"].
Bar listnew
A ranked list with a bar behind each name. Rows can link, filter the page, show their share and how they changed since the period before.
Activity heatmapnew
Activity per day, a column per week, like deploys over a year. Read days by pointer or keys, drag to choose a range, with streaks and weekday totals. Levels follow the spread of the days. No chart library.