About
A donut, pie, or half-donut chart for shadcn/ui with a center label, tooltip, and legend, built on shadcn's chart primitives. The half-donut form doubles as a simple gauge.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Donut Chart to your project and fits it to your theme.
Code
How Donut Chart is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
"use client"
import { DonutChart } from "@/components/ui/dashboardcn-donut-chart"
import { formatNumber } from "@/components/ui/dashboardcn-donut-chart"
const sources = [
{ name: "Institutional", value: 4_200_000, color: "var(--chart-2)" },
{ name: "Retail", value: 2_100_000, color: "var(--chart-1)" },
{ name: "Treasury", value: 900_000, color: "var(--chart-4)" },
]
export default function DonutChartHalfDemo() {
return (
<div className="w-full max-w-sm">
<DonutChart
data={sources}
startAngle={180}
sweep={180}
innerRadius={0.75}
centerLabel="Capital inflows"
valueFormatter={(v) => formatNumber(v, { format: "currency", maximumFractionDigits: 0 })}
centerValue={formatNumber(7_200_000, { format: "compact" })}
showLegend
className="max-h-56"
/>
</div>
)
}
















