Skip to content
GetUrUI

Donut Chart

.md

Donut whose arcs sweep in on springs; hovering a segment or legend row expands it and swaps the rolling centre total for that segment's share.

chartdonutpiesharebreakdownsvg

Installation

$npx shadcn@latest add @geturui/donut-chart
Download source (.zip)

Also installs: Odometer Number

Usage

usage.tsx
1import { DonutChart } from "@/components/charts/donut-chart";
2
3<DonutChart
4  title="Revenue by plan"
5  prefix="$"
6  data={[
7    { label: "Pro", value: 21480 },
8    { label: "Lifetime", value: 8740 },
9    { label: "Team", value: 3610 },
10  ]}
11/>

Props

PropTypeDefaultDescription
data*{ label: string; value: number; color?: string }[]—Segments in drawing order (clockwise from 12).
sizenumber220Diameter in px.
thicknessnumber26Ring thickness in px.
totalLabelstring"Total"Caption under the centre total.
prefix / suffixstring—Added around values, e.g. $.
valueFormatter(n: number) => string—Overrides value formatting.
titlestring—Caption and accessible name.

Accessibility

  • The SVG is an image labelled with every segment's share.
  • Legend rows are toggle buttons (aria-pressed); focusing one highlights its segment and the centre text updates politely.
  • Values and percentages are always shown in text beside the colour swatch.

Related