PieChart

A pie chart component for visualizing proportions and compositions. Comes in Pie and Donut variants, with customizable label position and center text.

2
Variants
3
Label Mode
3
Indicator
Recharts
Base

Playground

Preview
Pie
Variant
Label
Slices
Options
<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.

Legend<ChartLegend />
Center LabelCSS overlay (donut only)

Patterns

Common PieChart display patterns — choose based on your use case.

Default Pie

Basic pie chart

Donut

Donut + center label

925Total

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

Chrome275
Safari200
indicator="dot"

Line

Vertical line indicator

Chrome275
Safari200
indicator="line"

Dashed

Dashed line indicator

Chrome275
Safari200
indicator="dashed"

API

Component Structure

Chart— Recharts
.PieProps.Tooltip.TooltipContentProps.Legend.LegendContent

Props

Chart

config
ChartConfig

Chart configuration object (label and color definitions)

children
ReactElement

Recharts chart component

idundefined
string

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

activeShapetrue
boolean

Expands the slice on hover

innerRadius0 (pie) / 60 (donut)
number

Inner radius — auto-set by variant, but can be overridden directly

paddingAngle0
number

Gap between slices (degrees)

cornerRadius0
number

Rounded corners on slices

startAngle90
number

Start angle (90 = 12 o'clock)

endAngle-270
number

End angle

ChartTooltipContent

indicator"dot"
"dot" | "line" | "dashed"

Indicator shape

hideLabelfalse
boolean

Hide the label

hideIndicatorfalse
boolean

Hide the indicator

colorundefined
string

Directly set the indicator color

nameKeyundefined
string

Name mapping for data keys

labelKeyundefined
string

Label key mapping

labelFormatterundefined
(value, payload) => ReactNode

Custom label formatter

formatterundefined
(value, name, item, index, payload) => ReactNode

Custom value formatter

ChartLegendContent

hideIconfalse
boolean

Hide the icon

nameKeyundefined
string

Name mapping for data keys

verticalAlign"bottom"
"top" | "middle" | "bottom"

Vertical alignment

align"center"
"left" | "center" | "right"

Horizontal alignment

layout"horizontal"
"horizontal" | "vertical"

Layout direction

Customization

The donut center label uses a CSS overlay — any HTML content can be freely customized.

Number + label

925Total
<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

+12%Growth
<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

Revenue$4.2k+8.5%
<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

1
2
3
4
30%
7
Total82%
5
Desktop30%
6
Jan
Feb
Mar
Apr
May
1
Root
Chart wrapper
2
Chart Area
Plot area
3
Pie Segment
Data slice
4
Label
Slice label
5
Tooltip
Hover info
6
Legend
Series legend
7
Center Area
Donut center

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

TabFocus the chart area
Arrow KeysMove between slices

ARIA / WCAG

  • Tooltip provides data values as text
  • Legend identifies each slice
  • Color tokens support dark mode automatically
  • activeShape provides hover feedback
  • accessibilityLayer enables keyboard + screen reader support