Pie Chart

A pie and donut chart for proportional data with labels, legends, and nested ring support.

Usage

Browser Usage

Chrome
Safari
Firefox
Edge
"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

Chrome
Safari
Firefox
Edge
"use client";

import { PieChart } from "@thenamespace/uikit";
import { Card } from "@thenamespace/uikit/card";
import { ChartTooltip } from "@thenamespace/uikit/chart-tooltip";

Donut

Traffic Sources

Organic (4,500)
Direct (3,200)
Referral (2,100)
Social (1,400)
"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

4.5KDevices
Mobile2,800(62%)
Desktop1,200(27%)
Tablet500(11%)
"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

100GB used
Documents (42 GB)
Media (28 GB)
Apps (18 GB)
Other (12 GB)
"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

Q1
Q2
Q3
Q4
Last year (inner)This year (outer)
"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

1,140Total
Enterprise
340(29.8%)
Pro
520(45.6%)
Starter
280(24.6%)
"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 wrapping ResponsiveContainer and 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; use paddingAngle on <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.

PropTypeDefaultDescription
heightnumber300Chart height in pixels.
widthnumber | `${number}%` "100%"Chart width in pixels or percentage string.
childrenReactNodeRecharts 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.