Ballmac UI home

Chart Pie

A pie or donut with the total in the hole, outside labels, a pulled-out slice and a half ring, in a frame with a legend that switches slices off, a table of value and share, a written ranking, patterns and states.

6/6 checksv1.0.0Updated Oct 18, 2026
What changed

Visitors by source

Last 30 days

9,710 visitors in total across 4 groups. Search 43% (4,210), Direct 30% (2,890), Social 17% (1,630), Email 10% (980).

Installation

$ pnpm dlx shadcn@latest add @ballmac/chart-pie

Usage

import { ChartPie } from "@/components/ballmac/chart-pie"

The full example is in the Code tab above.

Examples

Full pie with labels

Accounts by plan

Percent of all accounts

100% in total across 3 groups. Paid 52% (52%), Trial 31% (31%), Free 17% (17%).

Half ring

Storage

10 GB plan

10,000 MB in total across 3 groups. Used 74% (7,420), Reserved 16% (1,580), Free 10% (1,000).
UsedReservedFree

A pulled-out slice

Monthly budget

Rent is the largest share

$3,500 in total across 5 groups. Rent 53% ($1,850), Food 18% ($640), Savings 14% ($480), Fun 9% ($320), Transport 6% ($210).

Patterns for color blindness

Browsers

Switch Patterns on to read the slices without color

17,780 visitors in total across 5 groups. Chrome 47% (8,420), Safari 29% (5,130), Firefox 11% (1,980), Edge 9% (1,610), Other 4% (640).

A goal ring with your own center

Quarterly goal

Revenue target

100% in total across 2 groups. Done 72% (72%), Left 28% (28%).
DoneLeft

API reference

PropTypeDefault
data*

One row per slice: its name under `nameKey`, its number under `valueKey`, and optionally a `label` and a `color`.

ChartRow[]—
nameKey

The key of each slice's name.

string"name"
valueKey

The key of each slice's number.

string"value"
valueLabel

What the numbers count, for the center and the table: "visitors".

string—
donut

A ring with a hole (default) or a full pie.

booleantrue
half

Draw only the upper half, like a gauge.

booleanfalse
centerLabel

Write the total in the hole of a donut. Pass your own `{ value, label }`, or false to leave it empty.

boolean | { value: string; label: string }true
labels

"outside" writes each slice's name and share beside it.

"none" | "outside""none"
highlight

A slice to pull out, by name.

string—
gap

Leave a small gap between slices.

booleantrue
tooltipbooleantrue
value*string—
label*string—

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
Arrow keysMove between slices (accessibilityLayer)
Tab, Enter / SpaceLegend buttons switch slices off and on; the Chart / Table switch shows value and share as a table
Screen readersThe summary lists every slice with its share and value, largest first

Quality scorecard

6/6

Every applicable check passes

Measured in Chromium 153.0.8010.12 on October 19, 2026, on version 1.0.0, across 6 examples.

How we measure
  • Passed: Accessibility scan

    No serious or critical issues in light and dark, on a phone and a desktop (axe-core 4.13.0, WCAG 2.1 AA and best-practice rules).

  • Passed: Small screens

    No sideways scrolling at 360, 390 or 1280 px wide.

  • Passed: Reduced motion

    No endless animation to begin with.

  • Not applicable: Right to left

    Not mirrored by design: Recharts draws its axes in SVG coordinates, which do not mirror.

  • Passed: Clean console

    No console errors or React hydration errors while loading.

  • Passed: Keyboard

    36 tab stops, each showing a visible change when it takes focus. 3 documented keys.

  • Not applicable: Loading, empty and error

    Does not show data or take submissions.

  • Passed: Automated tests

    Covered by charts-batch-families.test.tsx.

  • For information: Footprint

    2.7 KB of source (gzip) in 1 file. Installs recharts.

Automated checks find a subset of problems and do not replace testing with a screen reader and a keyboard in your own app. What they miss.

Use with AI

<ChartPie title description data={[{ name, label?, value, color? }]} valueLabel='visitors' />. donut (default) or donut={false}; half for a semicircle; centerLabel (true writes the total; or { value, label }); labels='outside'; highlight (a slice name); gap; legend; patterns; state. The legend switches slices off and the total and shares follow. Slices are rows, not series. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Chart Pie (@ballmac/chart-pie) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • A few parts of one whole (up to about six)
  • A goal or quota ring (two slices, custom centerLabel)

Not for

  • More than six categories or exact comparison (use chart-bar with layout='bars')
  • Change over time (use chart-area or chart-line)

Registry JSON: https://ui.ballmac.com/r/chart-pie.json

Credits

Free to use in personal and commercial projects.

Ballmac UI Pro

Need the whole screen, not one piece?

150 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.

Not ready? Try three Pro blocks free

Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.