Donut chart preview

Donut chart

A ring of rounded, gapped slices with a centred total, percentage pills and a legend; hovering or focusing a slice lifts it out and shows its value in the centre.

  • Group
    Charts
  • Origin
    Inspired · Original (this library)
  • License
    MIT
  • Added
    Oct 29
npx shadcn@latest add @deank/donut-chart

The registry stays private. Install from the repo with a GitHub token — see the README.

Usage

import { DonutChart } from "@/registry/components/donut-chart/donut-chart";

<DonutChart data={[/* … */]} label="…" />

Props

PropTypeDefaultDescription
dataDonutSlice[]
labelstringAccessible summary of the chart
centerLabel?string"Total"Small caption above the centre value; defaults to "Total"
centerValue?stringCentre value; defaults to the formatted sum of the slices
size?number240Outer diameter in px
thickness?number0.36Ring thickness as a fraction of the radius (0.2 to 0.6)
gap?number2.5Gap between slices in degrees
pillMin?number0.08Show a percentage pill on slices of at least this share (0 to 1); set 1 to hide them
showLegend?booleantrue
formatValue?(v: number) => string(v) => v.toLocaleString()

When to use

- Shares of one whole with two to about six parts: portfolio or budget allocation, traffic by source, plan mix - A dashboard card where the total matters as much as the split

When not to use

Comparing values across periods (use bar-chart); more than about six parts or parts that do not add up to a whole (use bar-chart); a single value against a target (use gauge or tick-meter).

Related

Bar chart · Gauge · Tick meter