PieChart
A pie chart component for visualizing proportions and compositions. Comes in Pie and Donut variants, with customizable label position and center text.
Playground
<Chart config={chartConfig} className="w-full mx-auto aspect-square max-h-[300px]">
<PieChart accessibilityLayer>
<ChartTooltip content={<ChartTooltipContent hideLabel />} />
<ChartLegend content={<ChartLegendContent nameKey="key" />} />
<ChartPie data={chartData} dataKey="value" nameKey="name" />
</PieChart>
</Chart>JSX Composition
Chart.* Import Chart.* from this library — other components from Recharts.
<ChartLegend />CSS overlay (donut only)Patterns
Common PieChart display patterns — choose based on your use case.
Default Pie
Basic pie chart
Donut
Donut + center label
Outside Labels
Outside labels + legend
Styled Donut
Padded, rounded donut
Tooltip Styles
Change the tooltip indicator shape via the indicator prop on ChartTooltipContent.
Dot (default)
Default dot indicator
indicator="dot"Line
Vertical line indicator
indicator="line"Dashed
Dashed line indicator
indicator="dashed"API
Component Structure
Chart— Recharts.PiePropsPie (variant, label, activeShape).TooltipTooltip wrapper.TooltipContentPropsTooltip content.LegendLegend wrapper.LegendContentLegend contentProps
Chart
config—ChartConfigChart configuration object (label and color definitions)
children—ReactElementRecharts chart component
idundefinedstringUnique chart ID (used for CSS variable scoping)
| Name | Type | Default | Description |
|---|---|---|---|
config | ChartConfig | — | Chart configuration object (label and color definitions) |
children | ReactElement | — | Recharts chart component |
id | string | undefined | Unique chart ID (used for CSS variable scoping) |
ChartPie
variant"pie""pie" | "donut"Shape — "donut" auto-sets innerRadius
label"none""none" | "outside" | "inside"Label position — outside: callout lines, inside: within slice (small slices auto-hidden)
labelContent"value""value" | "percent"Content shown in the label
activeShapetruebooleanExpands the slice on hover
innerRadius0 (pie) / 60 (donut)numberInner radius — auto-set by variant, but can be overridden directly
paddingAngle0numberGap between slices (degrees)
cornerRadius0numberRounded corners on slices
startAngle90numberStart angle (90 = 12 o'clock)
endAngle-270numberEnd angle
| Name | Type | Default | Description |
|---|---|---|---|
variant | "pie" | "donut" | "pie" | Shape — "donut" auto-sets innerRadius |
label | "none" | "outside" | "inside" | "none" | Label position — outside: callout lines, inside: within slice (small slices auto-hidden) |
labelContent | "value" | "percent" | "value" | Content shown in the label |
activeShape | boolean | true | Expands the slice on hover |
innerRadius | number | 0 (pie) / 60 (donut) | Inner radius — auto-set by variant, but can be overridden directly |
paddingAngle | number | 0 | Gap between slices (degrees) |
cornerRadius | number | 0 | Rounded corners on slices |
startAngle | number | 90 | Start angle (90 = 12 o'clock) |
endAngle | number | -270 | End angle |
ChartTooltipContent
indicator"dot""dot" | "line" | "dashed"Indicator shape
hideLabelfalsebooleanHide the label
hideIndicatorfalsebooleanHide the indicator
colorundefinedstringDirectly set the indicator color
nameKeyundefinedstringName mapping for data keys
labelKeyundefinedstringLabel key mapping
labelFormatterundefined(value, payload) => ReactNodeCustom label formatter
formatterundefined(value, name, item, index, payload) => ReactNodeCustom value formatter
| Name | Type | Default | Description |
|---|---|---|---|
indicator | "dot" | "line" | "dashed" | "dot" | Indicator shape |
hideLabel | boolean | false | Hide the label |
hideIndicator | boolean | false | Hide the indicator |
color | string | undefined | Directly set the indicator color |
nameKey | string | undefined | Name mapping for data keys |
labelKey | string | undefined | Label key mapping |
labelFormatter | (value, payload) => ReactNode | undefined | Custom label formatter |
formatter | (value, name, item, index, payload) => ReactNode | undefined | Custom value formatter |
ChartLegendContent
hideIconfalsebooleanHide the icon
nameKeyundefinedstringName mapping for data keys
verticalAlign"bottom""top" | "middle" | "bottom"Vertical alignment
align"center""left" | "center" | "right"Horizontal alignment
layout"horizontal""horizontal" | "vertical"Layout direction
| Name | Type | Default | Description |
|---|---|---|---|
hideIcon | boolean | false | Hide the icon |
nameKey | string | undefined | Name mapping for data keys |
verticalAlign | "top" | "middle" | "bottom" | "bottom" | Vertical alignment |
align | "left" | "center" | "right" | "center" | Horizontal alignment |
layout | "horizontal" | "vertical" | "horizontal" | Layout direction |
Customization
The donut center label uses a CSS overlay — any HTML content can be freely customized.
Number + label
<div className="absolute inset-0 flex flex-col items-center justify-center pointer-events-none">
<span className="text-3xl font-bold">925</span>
<span className="text-sm text-text-muted">Total</span>
</div>Icon + percent
<div className="absolute inset-0 flex flex-col items-center justify-center pointer-events-none">
<TrendingUp className="icon-md text-success" />
<span className="text-lg font-bold">+12%</span>
<span className="text-xs text-text-muted">Growth</span>
</div>Rich content
<div className="absolute inset-0 flex flex-col items-center justify-center pointer-events-none">
<span className="text-xs text-text-muted">Revenue</span>
<span className="text-2xl font-bold">$4.2k</span>
<span className="text-xs font-semibold text-success">+8.5%</span>
</div>Tip:The center label is implemented as a CSS overlay (absolute + pointer-events-none) — text, icons, or custom components can be placed freely.
Anatomy
Best Practices
Do
- ✓Keep slices to 5–6 max
- ✓Use donut variant to show totals or KPIs in the center
- ✓Provide exact values via Tooltip
- ✓Use Legend to identify each slice
- ✓Always enable accessibilityLayer
Don't
- ✗Don't use more than 7 slices — use BarChart instead
- ✗Avoid when many values are similar — differences won't be visible
- ✗Don't use for time-series data — use LineChart
- ✗Don't rely on color alone — combine with Legend or labels
Accessibility
Keyboard
ARIA / WCAG
- Tooltip provides data values as text
- Legend identifies each slice
- Color tokens support dark mode automatically
- activeShape provides hover feedback
accessibilityLayerenables keyboard + screen reader support