Donut Chart Segments
A donut whose segments sweep in one after another; hovering a segment or its legend row thickens it and swaps the centre total for that slice.
chartdonutpiesvglegend
Installation
Run the shadcn CLI in a project with Tailwind CSS. The component lands in components/pixelpapa/chart-donut-segments.tsx.
$pnpm dlx shadcn@latest add "https://pixelpapa.com/r/chart-donut-segments.json"Manual install+
1. Install the dependencies.
$pnpm add motion2. Copy the code from the Code tab above into your project. It imports the cn helper from @/lib/utils, which every shadcn project already has.
Build it with AI
Prefer to let an agent do the wiring? Copy this prompt, describe where the component should go, and paste.
AI prompt
Paste into Claude, Cursor, v0 or Lovable
Add the "Donut Chart Segments" component from PixelPapa UI to this project. What it is: A donut whose segments sweep in one after another; hovering a segment or its legend row thickens it and swaps the centre total for that slice. Category: Charts. Depends on: motion. 1. Install it with the shadcn CLI: npx shadcn@latest add "https://pixelpapa.com/r/chart-donut-segments.json" (If the CLI is unavailable, fetch that URL, write files[0].content to components/pixelpapa/chart-donut-segments.tsx and install the listed dependencies.) 2. Import it from "@/components/pixelpapa/chart-donut-segments" and place it where I describe below. 3. Keep its animation timings and accessibility attributes. Replace the demo copy and data with content that fits my product, and use my existing theme tokens (bg-background, text-foreground, bg-primary, border-border) rather than hard-coded colours. Where to use it: <describe the page and position here>
More charts
- Area Chart GradientA smooth SVG area chart that draws its line on mount, fades in a gradient fill and snaps a crosshair tooltip to the nearest point.
- Funnel Steps ChartA flowing horizontal funnel: each stage tapers into the next with a bezier, stages fade in left to right and hovering one shows its drop-off.
- Grouped Bar ChartSide-by-side SVG bars per category that grow from the baseline in a stagger, with a group highlight and a tooltip comparing every series.
- Heat Grid Week by HourA 7×24 SVG heatmap whose cells ripple in diagonally; hover or arrow-key between cells for a snapped tooltip, with peak hour called out.
- Inline SparklineA tiny table-cell sparkline that draws itself on mount, colours by trend and snaps a value bubble to the nearest point on hover.
- Multi Line Chart With LegendSeveral SVG lines draw in together; legend buttons toggle a series and the y-axis rescales while the remaining lines morph to fit.