Controls

Donut Chart

Effect
Preview
Reduced motion

Simulates prefers-reduced-motion for the demo. Off follows your system setting.

Keyboard stepping

Steps focus through the demo with ] and [. Tab, arrows, and Escape stay native so the component behaves as shipped.

Donut Chart
10.7KVisits

Traffic by source
SliceValueShare
Direct4.2K39%
Search3.1K29%
Social1.8K17%
Referral9509%
Email6206%

Donut Chart

A ring of soft rounded slices that shows how a total breaks down.

Installation

npx shadcn@latest add ikislay/pixel-ui/donut-chart

How to use

import { DonutChart } from "@/components/ui/donut-chart"
const data = [
{ label: "Direct", value: 4200 },
{ label: "Search", value: 3100 },
{ label: "Social", value: 1800 },
]
export function Demo() {
return <DonutChart label="Traffic by source" data={data} totalLabel="Visits" />
}

Source Code

// Loading…

Props

Options you can pass to customize this component.

Prop
Type
Description
data*
{ label: string; value: number; color?: string }[]

One entry per slice. Colors follow the chart palette in order unless you set one.

label*
string

Names the chart for screen readers and captions its data table.

format
(value: number) => string

Formats values wherever the chart shows them. Defaults to short numbers like 12.4K.

thickness
number

Width of the ring, on a 200 unit wide chart.

totalLabel
string

The caption under the total in the center.

className
string

Merged onto the root element.