npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-chart-donut.json --yesChart donut
ProA donut chart that shows how one whole splits into parts, each slice read on hover, on a press or from the keyboard, for React and Tailwind CSS. Part of Goop Pro.
What an agent sees
- ChartDonutLegendThe donut's legend under the ring
- ChartDonutTooltipContentThe tooltip's words for a held slice, in the theme's tooltip panel
import { ChartDonutLegend, ChartDonutTooltipContent, ChartDonut } from '@/components/ui/goop/chart-donut';
<ChartDonut
title="Interviews by length"
description="Recorded this month"
summary="Interviews recorded this month by length: half of the 46 ran 30 to 60 minutes."
config={{ interviews: { label: 'Interviews' } }}
categoryKey="length"
data={[
{ length: 'Under 30 min', interviews: 14 },
{ length: '30 to 60 min', interviews: 23 },
{ length: 'Over 60 min', interviews: 9 },
]}
unit="interviews"
caption="Total"
/>Point at a slice or a legend row and it slides out, the hole reading it; click to pin, Escape to let go (the line under it says which is pinned); switch the slices, the caption, the hole’s value, a slice pinned at first, the legend beside, loading. The recordings are ours; the slice pinned is only written under it.
When to use
- A donut chart that shows how one whole splits into parts, each slice read on hover, on a press or from the keyboard.
- Also called: pie chart or ring chart.
Installation
Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Chart donut on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-chart-donut.json --yesAdd the Goop Chart donut to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { ChartDonutLegend, ChartDonutTooltipContent, ChartDonut } from '@/components/ui/goop/chart-donut';
<ChartDonut
title="Interviews by length"
description="Recorded this month"
summary="Interviews recorded this month by length: half of the 46 ran 30 to 60 minutes."
config={{ interviews: { label: 'Interviews' } }}
categoryKey="length"
data={[
{ length: 'Under 30 min', interviews: 14 },
{ length: '30 to 60 min', interviews: 23 },
{ length: 'Over 60 min', interviews: 9 },
]}
unit="interviews"
caption="Total"
/>- Fits: overview: body.
- height, width, padding, gap, background, text, motion: add no class for these.
API reference
| Option | Type | What it does |
|---|---|---|
| config | NoInfer<ChartConfig<ChartKey<Data>>> | The series, in order, each keyed by a field of the rows: its label, and dashed if wanted. |
| data | Data | The rows, a slice each: of the caller's own type (an interface too) or ChartRow. |
| categoryKey | NoInfer<ChartKey<Data>> | The field of each row that holds its category. |
| caption? | string = 'Total' | The short words above the hole's value. |
| total? | number | The number in the hole; the shown slices' sum when left out. |
| otherLabel? | string = 'Other' | The name of the slice the rows past the fourth are folded into. |
| pinned? | number | null | The pinned slice, by its place from 0, or null: held by the page, with onPinnedChange. |
| defaultPinned? | number | The slice pinned when the chart mounts, by its place from 0. |
| onPinnedChange? | (pinned: number | null) => void | Called with the slice a press pins, or null when let go. |
- Takes every prop of ChartContainer but plot, children, legend, encode, markers and endLabels (its page: chart.md)
- State: pinned (pinned / defaultPinned / onPinnedChange)
- Types: Slice = { name: string; value: number; series: number; members?: string[] }
| Part | What it is |
|---|---|
| ChartDonutLegend | The donut's legend under the ring |
| ChartDonutTooltipContent | The tooltip's words for a held slice, in the theme's tooltip panel; payload?: ReadonlyArray<{ payload?: Partial<Slice> }> — The held slice's entry; className?: string — Classes for the panel, last |
- data-slot values (to select a part by): chart-donut, chart-donut-caption, chart-donut-inner, chart-donut-item, chart-donut-legend, chart-donut-legend-item, chart-donut-legend-members, chart-donut-readout, chart-donut-share, chart-donut-status, chart-donut-value
Keyboard
| Key | What it does |
|---|---|
| Tab | Focus the plot, then the legend's row |
| ArrowLeft | Move the held slice |
| ArrowRight | Move the held slice |
| Escape | Hide the tooltip and let a pinned slice go |
| ArrowDown | Move to the next legend row, wrapping |
| ArrowUp | Move to the previous legend row, wrapping |
| Home | Move to the first legend row |
| End | Move to the last legend row |
| Enter | Hide or show the legend row's slice |
| Space | Hide or show the legend row's slice |
Accessibility
- The native element answers the keyboard.
- hover: the browser's own (:hover): write nothing
Motion
- The part sets its own motion: add no transition or animation of your own.
- How the theme moves, and how to move your own parts the same way: Motion.
Notes for AI
Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.