Donut and pie chart
Shares of a whole as a ring, or with no hole as a pie chart. The slice under the pointer stays bright while the rest step back and its value rolls into the centre, and new data moves every slice by its angles from where it is.
Examples
New data
Each slice moves by its angles to the new month, from wherever it is. The slice under the pointer stays bright while the rest step back, and its value rolls into the centre.
Pie chart
With innerRadius={0} the ring closes into a pie. Labels with position='inside' sit on their slices, in white or black, whichever reads on the colour, and sliceGap={0} closes the gaps.
Labels
DonutChartLabels writes each slice’s value, share or name past the ring, on a short line. A label with no room is skipped.
Selected
With selected, a press or the menu picks a slice, which stays bright and keeps its value in the centre. With grow, it grows out of the ring too.
Rings
Each DonutChartRing adds a ring inside for another value of the same slices, such as last year’s. The tooltip gives every ring’s value.
Patterns
patterns lays a fine pattern over each slice after the first, so slices differ by more than colour, in grey and in print too.
Synced
Charts in a ChartGroup share the slice under the pointer by its key, so pointing at a region on one lights it on the other.
Installation
npx shadcn@latest add https://kinoui.com/r/donut-chart.json- Files
lib/number-format.tslib/reduce-motion.tslib/resize.tslib/roll.tsxlib/refs.tslib/swap.tsxlib/run-progress.tscomponents/kino/animated-number.tsxlib/scroll.tslib/popup.tslib/glide.tsxcomponents/kino/tooltip.tsxlib/cut.tsxlib/announce.tsxcomponents/kino/spinner.tsxcomponents/kino/button.tsxlib/chart-math.tslib/controllable.tslib/chart-core.tsxlib/highlight.tscomponents/kino/chart.tsxlib/placeholder.tscomponents/kino/donut-chart.tsx- Packages
@base-ui/reactclass-variance-authorityd3-array- Global CSS
- the feels, the density tokens, the shape tokens and the success and warning colours
New to Kino? Installation covers what your project needs first and the @kino namespace.
The CLI keeps any of these colours your project already has, such as the chart colours shadcn init writes. To use Kino’s, set them in your global CSS:
:root { --chart-1: oklch(0.62 0.16 250); --chart-2: oklch(0.54 0.18 257); --chart-3: oklch(0.47 0.21 263); --chart-4: oklch(0.4 0.19 268); --chart-5: oklch(0.33 0.15 272);}.dark { --chart-1: oklch(0.82 0.09 245); --chart-2: oklch(0.74 0.13 250); --chart-3: oklch(0.67 0.17 257); --chart-4: oklch(0.61 0.19 263); --chart-5: oklch(0.55 0.2 268);}API reference
DonutChart
DonutChartCentre
DonutChartLabels
DonutChartRing
Data attributes
CSS variables
Accessibility
- The ring is one stop in the tab order: a slider over the slices. The arrow keys step round, Home and End go to the first and last, and each slice’s name, value and share are read as the slider’s value.
- A hidden table holds every slice’s value and share, with the total, for screen readers and for copying.
- Loading, an error and new data are announced in a status region.
- Each slice is named in the legend, the tooltip and the centre, so none relies on colour alone;
patternsadds a pattern too. Forced colours draw each slice in a system colour. - A slice too small to see is drawn a few pixels long, so it shows and the pointer can find it.
- Labels repeat what the tooltip and the data table say, so screen readers skip them. With rings, the tooltip, the table and the slider read every ring’s value.
- When the system asks for less motion, slices move to their place at once and only fade.