Donut Chart
donut-chartPart of a whole as a ring with the total in the centre. The legend is a list of buttons with values and percentages, and hovering or tabbing through it lifts the slice and shows its value in the middle.
import { DonutChart } from "@/components/forme/donut-chart/donut-chart";
const money = new Intl.NumberFormat("en-US", {
style: "currency",
currency: "USD",
maximumFractionDigits: 0,
});
export function DonutChartDemo() {
return (
<div className="w-full max-w-lg rounded-xl border border-border bg-card p-5 shadow-xs">
<p className="text-title-2-semibold">Cloud spend, September</p>
<DonutChart
className="mt-5"
label="Cloud spend by service, September"
totalLabel="Spend"
formatValue={(value) => money.format(value)}
data={[
{ label: "Compute", value: 18420 },
{ label: "Database", value: 9310 },
{ label: "Storage", value: 4870 },
{ label: "Bandwidth", value: 3260 },
{ label: "Other", value: 1140 },
]}
/>
</div>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
DonutChart
Part of a whole, as a ring with the total in the middle.
| Prop | Type | Default | Description |
|---|---|---|---|
data* | readonly DonutSlice[] | — | Five slices or fewer reads best; fold the tail into "Other". |
label* | string | — | |
totalLabel | string | "Total" | What the centre says about the total: "Visitors", "Spend". |
formatValue | (value: number) => string | (value) => value.toLocaleString("en-US") | |
size | number | 168 | The ring's outer diameter in pixels. |
className | string | — |
Related


Area Chart
A line or area chart in plain SVG with no chart library. A crosshair snaps to the nearest point and lists every series, arrow keys walk it, round tick values, a legend from two series up, and a hidden table so screen readers get the numbers.
data display

Bar Chart
A single or grouped column chart in plain SVG. Columns are capped at 24px with rounded tops and 2px gaps, the hovered category lifts while the rest recede, arrow keys read each category, and a hidden table carries every value.
data display

Chart
The tooltip and legend every Forme chart shares: a floating panel with a colour, a name and a right-aligned value per series, and a row of swatches. Installed with any chart; use them directly to give a chart of your own the same finish.
data display