Donut Chart

Rounded share segments with a linked center readout and legend.

Preview

$115,150

Monthly revenue

Select a plan to filter

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/donut-chart

API Reference

DonutChart

segments
readonly DonutSegment[]
—
thickness?
number

Ring thickness in viewBox units; the chart is 200 wide.

—
gap?
number

Degrees of empty space between neighbouring segments.

—
activeId?
string | null

Focused segment, shared by the ring, center, and legend. Controlled.

—
defaultActiveId?
string | null
—
onActiveChange?
((id: string | null) => void)
—
onSelect?
((id: string) => void)

Called when a legend item is clicked.

—
selectedId?
string | null

Marks a legend item as pressed.

—
formatValue?
((value: number) => string)
—
label?
string

Accessible name for the chart.

—
className?
string
—

DonutChartCenter

children?
((segment: PlacedSegment | null, total: number) => ReactNode)

Custom content for the hole. Receives the focused segment, or null when nothing is focused, and the total. Defaults to a rolling value and caption.

—
totalLabel?
ReactNode

Caption under the total when nothing is focused.

Total
className?
string
—

DonutChartLegend

renderDetail?
((segment: PlacedSegment) => ReactNode)

Extra line under each name, such as terms or a note.

—
renderValue?
((segment: PlacedSegment) => ReactNode)

Trailing value. Defaults to the share and formatted value.

—
className?
string
—

DonutChartPlot

children?
ReactNode

Centered overlay, usually `DonutChartCenter`.

—
className?
string
—

Updated