073
A donut and its legend wired both ways: point at a slice or a row and the slice swells, the rest step back and the centre figure rolls to it; click a row to take it out of the total.
akadonut·pie·legend
Run this in any project set up for the shadcn CLI. It copies the Donut Legend source into your components folder, so the code is yours to change.
npx shadcn@latest add https://devl.dev/r/donut-legend.jsonImport it and render it. Every prop has a typed default, so it works straight away, and you pass your own data when you’re ready.
import { DonutLegend } from "@/components/donut-legend";
export default function Page() {
return <DonutLegend />;
}A free React component in the Numbers collection, written in TypeScript with Tailwind CSS on coss ui. MIT licensed.
Read from the Donut Legend source. Everything is optional unless it says required.
| Prop | Type | Default |
|---|---|---|
| title | string | "Cloud spend" |
| caption | string | "October, month to date" |
| slices | DonutSlice[] | defaultSlices |
| totalLabel | string | "Total" |
| format | Intl.NumberFormatOptions | { style: "currency", currency: "USD", maximumFractionDigits: 0 } |
| locale | string | "en-US" |
| className | string | — |