Pie Chart
A pie and donut chart for proportional data with labels, legends, and nested ring support.
Usage
Browser Usage
"use client";
import { PieChart } from "@thenamespace/uikit";
import { Card } from "@thenamespace/uikit/card";
import { ChartTooltip } from "@thenamespace/uikit/chart-tooltip";Anatomy
Import the PieChart component and access all parts using dot notation.
import { PieChart } from "@thenamespace/uikit";
<PieChart>
<PieChart.Pie>
<PieChart.Cell />
<PieChart.Label />
</PieChart.Pie>
<PieChart.Tooltip />
</PieChart>;Custom Tooltip
Market Share
"use client";
import { PieChart } from "@thenamespace/uikit";
import { Card } from "@thenamespace/uikit/card";
import { ChartTooltip } from "@thenamespace/uikit/chart-tooltip";Donut
Traffic Sources
"use client";
import { PieChart } from "@thenamespace/uikit";
import { Card } from "@thenamespace/uikit/card";
import { ChartTooltip } from "@thenamespace/uikit/chart-tooltip";Donut With Content
Connected Devices
"use client";
import { PieChart } from "@thenamespace/uikit";
import { Card } from "@thenamespace/uikit/card";
import { ChartTooltip } from "@thenamespace/uikit/chart-tooltip";Donut With Label
Storage Usage
100 GB of 128 GB used
"use client";
import { PieChart } from "@thenamespace/uikit";
import { Card } from "@thenamespace/uikit/card";
import { ChartTooltip } from "@thenamespace/uikit/chart-tooltip";Nested Donut
Revenue: This Year vs Last
"use client";
import { PieChart } from "@thenamespace/uikit";
import { Card } from "@thenamespace/uikit/card";
import { ChartTooltip } from "@thenamespace/uikit/chart-tooltip";With Breakdown
Users by Plan
"use client";
import { PieChart } from "@thenamespace/uikit";
import { Card } from "@thenamespace/uikit/card";
import { ChartTooltip } from "@thenamespace/uikit/chart-tooltip";CSS Classes
Element Classes
.pie-chart— Root container wrappingResponsiveContainerand the Recharts chart.
Recharts Theming
The following CSS rules target Recharts internal class names to apply Namespace UIKit design tokens automatically:
.pie-chart .recharts-pie-sector path— Pie sector strokes. Removed to avoid messy convergence at the center; usepaddingAngleon<PieChart.Pie>for clean slice separation..pie-chart .recharts-pie-label-text— Outside label text. 11px muted..pie-chart .recharts-pie-label-line— Connector lines from slice to label. Muted at 0.3 opacity..pie-chart .recharts-label— Center label text for donut charts. Uses foreground color..pie-chart .recharts-tooltip-cursor— Tooltip cursor. Hidden for pie charts..pie-chart .recharts-tooltip-wrapper— Tooltip wrapper. Elevated z-index to render above center content.
API Reference
PieChart
The root wrapper. Renders a ResponsiveContainer + Recharts PieChart with Namespace UIKit CSS theming applied automatically.
| Prop | Type | Default | Description |
|---|---|---|---|
height | number | 300 | Chart height in pixels. |
width | number | `${number}%` | "100%" | Chart width in pixels or percentage string. |
children | ReactNode | — | Recharts child components (PieChart.Pie, PieChart.Cell, etc.). |
Also supports all native div HTML attributes.
PieChart.Pie
Re-exported Recharts Pie component. Follows the Recharts Pie API.
PieChart.Cell
Re-exported Recharts Cell component. Follows the Recharts Cell API.
PieChart.Label
Re-exported Recharts Label component. Follows the Recharts Label API.
PieChart.Tooltip
Re-exported Recharts Tooltip component. Follows the Recharts Tooltip API. Use with PieChart.TooltipContent for styled tooltips.
PieChart.TooltipContent
Pre-built tooltip renderer for Recharts. Pass as the content prop of PieChart.Tooltip. See ChartTooltip for full props.