Donut and pie chart
Parts of a whole as a ring, or as a pie with no hole. The hovered slice stays bright while the rest dims and its value rolls into the centre, and new data moves each slice 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/dates.tslib/chart-math.tslib/chart-scale.tslib/chart-frame.tslib/refs.tslib/reduce-motion.tslib/resize.tslib/live.tsxlib/chart-live.tslib/chart-live-clock.tsxlib/scroll.tslib/swap.tsxlib/popup.tslib/glide.tsxlib/keys.tsxcomponents/kino/kbd.tsxcomponents/kino/tooltip.tsxlib/cut.tsxlib/number-format.tslib/roll.tsxlib/run-progress.tscomponents/kino/animated-number.tsxlib/announce.tscomponents/kino/spinner.tsxcomponents/kino/button.tsxlib/controllable.tslib/chart-root.tsxlib/chart-state.tslib/chart-agent.tslib/chart-base.tsxlib/chart-cartesian-reader.tslib/chart-cartesian.tsxlib/chart-list.tsxlib/chart-list-reader.tslib/chart-tree-reader.tslib/chart-flow-reader.tslib/chart-grid-reader.tslib/highlight.tscomponents/kino/chart.tsxlib/chart-centre.tsxlib/chart-radial.tsxlib/placeholder.tscomponents/kino/donut-chart.tsx- Packages
@ui-sdk/core@ui-sdk/reactclass-variance-authorityd3-arrayd3-shape- 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.42 0.1 248); --chart-2: oklch(0.53 0.12 222); --chart-3: oklch(0.6 0.11 185); --chart-4: oklch(0.65 0.17 132); --chart-5: oklch(0.72 0.154 106.7); --chart-accent: oklch(0.795 0.171 71.2);}.dark { --chart-1: oklch(0.6 0.15 255); --chart-2: oklch(0.7 0.13 222); --chart-3: oklch(0.79 0.13 185); --chart-4: oklch(0.82 0.15 128); --chart-5: oklch(0.72 0.154 106.7); --chart-accent: oklch(0.795 0.171 71.2);}API reference
DonutChart
The chart: a <figure> named by label, which draws the ring and holds the chart’s parts. Other props go to the figure. The config’s keys are the slices. The props from data to messages are the ones every chart takes, less those for a value axis.
DonutChartCentre
What sits in the hole: the total of the slices shown, and the value and name of the slice under the pointer, the keys, or picked, rolling in as it changes. A pie, or a hole under 0.4 of the ring, has no room for it, so it draws nothing. Other props go to its layer.
DonutChartLabels
Writes on or beside each slice of the outer ring, and travels round with it. A label with no room, or one that would cover a bigger slice’s, is skipped. Outside, the ring makes room for the labels, so like every part the range reaches for, it sits straight inside the chart, or in a fragment there, in a file marked use client. Other props go to its layer.
DonutChartRing
Another ring inside the chart’s own, for a second value of the same slices. Rings share the room from the hole to the edge evenly, outermost first, and light up together.
ChartTooltip
What is under the pointer or the focus, in the chart’s own words: on a chart with series, the values of the category or the time. It shows at once and slides from one to the next. Other props go to its popup.
ChartLegend
A toggle for each series that shows and hides it. Pointing at one, or focusing it, brings its series forward. Takes position, top or bottom.
ChartGroup
Charts inside it share the category under the pointer or the focus, by its key, so pointing at a day on one lights it on all of them.
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.
- The chart is a
<figure>named bylabel. - Escape closes the tooltip and nothing above the chart.
- The legend’s toggles say whether each series shows. When every series is hidden, a button shows them all again and takes the focus.
For agents
What an agent reads on this example with snapshot(), and the actions it can call with act().
The Agent bridge page sets up snapshot() and act() in your app.