Charts

DonutChart

Parts of a whole as a ring, with content in the middle and a legend of values and shares. Slices draw in once and lift on hover.

Usage

Use it for:

  • One whole split into 2–6 parts (spend by category, task status).

Avoid it when:

  • Comparing parts across several wholes: use a stacked BarChart.
  • More than ~6 slices: group the small ones into "Other" or use a BarChart.
  • Precise comparison of similar values: bars read better.

Installation

Install the package (React 19):

terminal
npm install @krackedui/motion

Import the styles once, in your app entry or root layout:

/src/main.tsx
import '@krackedui/motion/styles.css';

Examples

Spend by category

Spent$2,360
Use the arrow keys to read each value.
October spend by category
CategoryValueShare
Housing$1,45061.4%
Food$41217.5%
Transport$1646.9%
Shopping$23810.1%
Utilities$964.1%

Small, without legend

75%
Use the arrow keys to read each value.
Sprint: 18 of 24 tasks done
CategoryValueShare
Done1875%
Open625%

API Reference

DonutChart

PropTypeDefault
data
{ label: string; value: number; color?: Color }[]
center
ReactNode
size
number
176
thickness
number
14% of size
legend
boolean
true
label
string
valueFormat
(value: number) => string
grouped digits
className
string
style
CSSProperties
id
string

Accessibility

Keyboard:

  • Tab: focuses the chart (focus ring).
  • → / ↓ and ← / ↑: move to the next / previous data point and show its tooltip.
  • Home / End: first / last point. Escape: hide the tooltip.

ARIA and semantics:

  • The SVG is role="img" named by label, with a description of the keys.
  • A visually hidden <table> (caption = label) holds every value, formatted with valueFormat, for screen readers.
  • Keyboard moves are read by a polite live region ("Mar: Revenue $5,150, Spending $1,808").
  • Series are named in the legend, tooltip and table, so color is never the only key.
  • The entrance animation does not play under reduced motion; the chart renders in its final state on the server.
© 2026 Motion. Internal documentation.