# Donut Chart with Rounded Arc Corner Caps

> Segmented donut ring visualization with smooth rounded arc endpoints.

A shadcn/ui block from the [@paceui](https://paceui.com/?utm_source=shadcn.exchange) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/paceui/tanstack-charts-rounded-donut).

- Page, with a live preview: https://shadcn.exchange/r/paceui/tanstack-charts-rounded-donut
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/paceui/tanstack-charts-rounded-donut-light-a706b61f1188fb81.png
- Registry item: https://paceui.com/r/tanstack-charts-rounded-donut.json
- Listed: 2026-10-21, source last changed 2026-10-21

## Install

```bash
npx shadcn@latest add https://shadcn.exchange/r/paceui/tanstack-charts-rounded-donut.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- npm packages: `@tanstack/charts`, `@tanstack/react-charts`
- Registry items: `card`

## Files

### `components/tanstack-charts/pie/rounded-donut.tsx`

```tsx
import { type ChartPoint, defineChart } from "@tanstack/charts";
import { motion } from "@tanstack/charts/motion";
import { pie, polar, radialArc } from "@tanstack/charts/polar";
import { tooltip } from "@tanstack/charts/tooltip";
import { Chart } from "@tanstack/react-charts/core";
import { useMemo } from "react";

import { CircleDot } from "lucide-react";

import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";

interface DonutSegment {
    category: string;
    value: number;
}

const motionRenderer = motion({
    initial: "always",
    transition: { type: "spring", stiffness: 170, damping: 18, mass: 1 },
});

const gapAngle = (Math.PI / 180) * 4;
const categories = ["North America", "Europe", "Asia Pacific", "Latin America", "Middle East"];
const colors = ["var(--chart-1)", "var(--chart-2)", "var(--chart-3)", "var(--chart-4)", "var(--chart-5)"];

function generateDemoData(): DonutSegment[] {
    return [
        { category: "North America", value: 38 },
        { category: "Europe", value: 26 },
        { category: "Asia Pacific", value: 20 },
        { category: "Latin America", value: 10 },
        { category: "Middle East", value: 6 },
    ];
}

function shadcnTooltipContent<TDatum>(points: readonly ChartPoint<TDatum>[]) {
    if (points.length === 0) return { title: "", rows: [] };
    const d = points[0].datum as DonutSegment;
    if (!d) return { title: "", rows: [] };
    return {
        title: d.category,
        rows: [{ label: "Regional Revenue", value: `${d.value}%`, color: "var(--chart-1)" }],
    };
}

export function RoundedDonut() {
    const data = useMemo(() => generateDemoData(), []);

    const definition = useMemo(() => {
        const arcs = pie(data, {
            value: "value",
            gapAngle,
        });

        return defineChart(
            {
                renderer: motionRenderer,
                scales: {
                    x: null,
                    y: null,
                },
                marks: [
                    polar({
                        radiusRatio: 0.78,
                        scales: {
                            angle: null,
                            radius: null,
                        },
                        marks: [
                            radialArc(arcs, {
                                id: "rounded-slices",
                                key: "category",
                                innerRadius: ({ radius }) => radius * 0.58,
                                cornerRadius: 8,
                                color: "category",
                            }),
                        ],
                    }),
                ],
                color: { domain: categories, range: colors },
                margin: { top: 20, right: 20, bottom: 20, left: 20 },
                theme: {
                    foreground: "var(--muted-foreground)",
                    grid: "var(--border)",
                    background: "transparent",
                },
            },
            {
                keyboard: true,
                tooltip: {
                    use: tooltip,
                    className: "font-sans shadow-none rounded-md bg-popover text-popover-foreground border p-2 text-xs",
                    anchor: "pointer",
                    placement: "auto",
                    content: (points) => shadcnTooltipContent(points),
                },
            },
        );
    }, [data]);

    return (
        <Card className="w-full max-w-xl">
            <CardHeader>
                <CardTitle>Donut Chart with Rounded Arc Corners & Sector Gaps</CardTitle>
                <CardDescription>
                    Segmented donut ring visualization with explicit corner radiuses and angular padding gaps
                </CardDescription>
            </CardHeader>
            <CardContent>
                <div className="h-[250px] w-full">
                    <Chart
                        definition={definition}
                        renderer={motionRenderer}
                        height={250}
                        ariaLabel="Donut Chart with Rounded Arc Corners & Sector Gaps Chart"
                    />
                </div>
            </CardContent>
            <CardFooter className="flex-col items-start gap-2 text-sm">
                <div className="flex items-center gap-2 leading-none font-medium">
                    Rounded arc corners deliver modern smooth pill aesthetics{" "}
                    <CircleDot className="h-4 w-4 text-emerald-500" />
                </div>
                <div className="text-muted-foreground leading-none">
                    `cornerRadius: 8` and `gapAngle` parameters sculpt pill-shaped ring sectors
                </div>
            </CardFooter>
        </Card>
    );
}

export default RoundedDonut;
```
