Donut chart
Revenue by plan donut whose segments draw around the ring, with a count-up centre and a lens glint at the start angle.
Preview
Resize it, switch the theme, replay the entrance — or read the source.
Revenue by plan
Share of MRR by plan.
Installation
Add the block to a project that already uses shadcn/ui.
npx shadcn@latest add https://prequelui.terravidhal.me/r/donut-chart.jsonRequires a project that already uses shadcn/ui on React and Tailwind CSS v4. The block is copied into your project as a single file you own and can edit.
Usage
Import the named export and render it with your own data.
Every prop is optional and ships with deterministic demo data, so a bare render shows the block at its default. Pass props to plug in your own data and formatters.
import { DonutChart } from "@/components/prequel/donut-chart/donut-chart";
export default function DashboardPage() {
return <DonutChart />;
}import { DonutChart } from "@/components/prequel/donut-chart/donut-chart";
export default function DashboardPage() {
return <DonutChart />;
}Props
Every prop is optional and ships with demo-data defaults.
| Prop | Type | Description |
|---|---|---|
className | string | Extra classes merged onto the root element. |
title | string | — |
description | string | — |
segments | DonutChartSegment[] | — |
valuePrefix | string | — |
totalLabel | string | Label shown in the centre when no segment is active. |
formatValue | (value: number) => string | — |
formatCenterValue | (value: number) => string | Formats the big centre value; defaults to compact notation (e.g. "$100k"). |
formatShare | (share: number) => string | — |
Accessibility
The rules every PrequelUI block follows, verified against this block's source.
Charts and graphics expose a text summary via role="img" and an aria-label describing the data.
Interactive charts respond to arrow keys, Home and End, and show tooltips on keyboard focus.
Every button carries a visible focus ring so keyboard users can always see where they are.
The block honours prefers-reduced-motion: animations are skipped and content is fully visible.
Live updates run on timers inside effects and pause when the block is off-screen or hovered.