suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
  • AI
GitHubCreate
DocsComponentsPatternsInteractionsChartsBlocksAICreate
Charts70
  • Overview
  • Area Chart
  • Bar Chart
  • Line Chart
  • Pie Chart
  • Radar Chart
  • Radial Chart
  • Tooltip Chart

suiss/ui ยท Chart

Pie Chart

Ten pie and donut charts for showing parts of a whole, with labels, legends, a centered total, nested rings and highlighted slices.

Pie Chart is an open-source chart from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.

Pie charts show how a whole splits into a few parts. Use the default pie or a donut for up to five or six slices, put the total in the center of a donut, and label slices directly or with a legend when the names are long. The nested variant shows groups and their members in two rings, and the active and separated variants draw attention to one slice.

Each chart is built on the Chart and Card components.

Every variant below is its own registry item, so you can add only the ones you need. Each one renders the same design on React, React Native, SwiftUI and Jetpack Compose.

Default

A full pie split into five device slices, separated by thin card-colored borders.

components/charts/pie-chart-default.tsx
"use client"

import { Pie, PieChart } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,

A full pie split into five slices separated by thin gaps, with a tooltip for each slice. Use it for a quick part-to-whole view of a small number of categories.

Give each record a category key, a value and a fill that references its color, and add a label and color for every key to chartConfig. Point dataKey and nameKey on the Pie at your value and category fields. Pies work best with about five slices or fewer; group the rest into an Other slice.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-default

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-default
  1. Install the following dependencies:
$ pnpm add recharts
  1. Add the pieces it builds on: Card, Chart.

  2. Copy and paste the following code into your project.

components/charts/pie-chart-default.tsx
  1. Update the import paths to match your project setup.

Usage

import { PieChartDefault } from "@/components/charts/pie-chart-default"
<PieChartDefault />
Web

Web preview

uniwind/components/charts/pie-chart-default.tsx
swift/Charts/PieChartDefault.swift
kotlin/charts/PieChartDefault.kt

The simplest PieChart: one Pie inside a Card, with slices separated by a thin stroke in the card color. chartData holds one record per device with a users count. Pressing a slice shows a tooltip with its name and value.

Replace chartData with your records and keep dataKey and nameKey in step with your field names. Add one entry per slice to chartConfig with its label and color; the component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-default

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-default
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-default

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-default --platform swift
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-default

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-default --platform kotlin

The CLI also adds what it builds on: Card, Chart.

  1. Add the pieces it builds on: Card, Chart.

  2. Copy and paste the following code into components/charts/pie-chart-default.tsx:

uniwind/components/charts/pie-chart-default.tsx
  1. Update the import paths to match your project setup.
  1. Add the pieces it builds on: Card, Chart.

  2. Copy and paste the following code into components/charts/pie-chart-default.tsx:

nativewind/components/charts/pie-chart-default.tsx
  1. Update the import paths to match your project setup.
  1. Add the pieces it builds on: Card, Chart.

  2. Copy and paste the following code into components/charts/pie-chart-default.tsx:

stylesheet/components/charts/pie-chart-default.tsx
  1. Update the import paths to match your project setup.
  1. Target iOS 17 or later.

  2. Copy the theme files every view uses:

swift/Theme/Theme.swift
swift/Theme/Tokens.swift
  1. Copy the source and every file it uses:
swift/Charts/PieChartDefault.swift
swift/Components/Card.swift
swift/Components/Chart.swift
swift/Components/Haptics.swift
swift/Components/Item.swift
swift/Components/Separator.swift
  1. Add the files to your app target.
  1. Apply the Compose compiler plugin, enable Compose, set compileSdk to 37 or higher and minSdk to 24 or higher, and add the dependencies:
build.gradle.kts
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
}
  1. Copy the theme files every view uses:
kotlin/theme/Theme.kt
kotlin/theme/Tokens.kt
  1. Copy the source and every file it uses:
kotlin/charts/PieChartDefault.kt
kotlin/components/Card.kt
kotlin/components/Chart.kt
kotlin/components/Content.kt
kotlin/components/FormSupport.kt
kotlin/components/Haptics.kt
kotlin/components/Icon.kt
  1. Update the com.esuiss.ui package names to match your project.

Usage

import { PieChartDefault } from "@/components/charts/pie-chart-default"
<PieChartDefault />
import SwiftUI

struct PieExample: View {
  var body: some View {
    PieChartDefault()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.PieChartDefault

@Composable
fun PieExample() {
    PieChartDefault()
}

Active

A donut where one slice is enlarged and outlined with an outer arc to highlight it.

components/charts/pie-chart-active.tsx
"use client"

import { Pie, PieChart, Sector } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,

A donut with one slice pulled outward and traced by a thin outer arc, so a single category stands out from the rest. Use it to call attention to the segment a page is about, such as the current plan or the user's own device.

Give each record in chartData a value and a fill that points at its color in chartConfig. Set ACTIVE to the index of the slice to emphasize; the highlight does not follow hover, so drive ACTIVE from state if it should follow a selection.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-active

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-active

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartActive } from "@/components/charts/pie-chart-active"
<PieChartActive />
Web

Web preview

uniwind/components/charts/pie-chart-active.tsx
swift/Charts/PieChartActive.swift
kotlin/charts/PieChartActive.kt

A PieChart donut inside a Card, showing users by device. chartData holds one record per device with a users count. The Pie shape callback enlarges the slice at index ACTIVE and adds a thin arc outside it. Pressing a slice shows a tooltip with its name and value.

Replace chartData with your records and keep dataKey and nameKey in step with your field names. Add one entry per slice to chartConfig with its label and color; change ACTIVE to highlight a different slice. The component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-active

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-active
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-active

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-active --platform swift
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-active

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-active --platform kotlin

The CLI also adds what it builds on: Card, Chart.

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartActive } from "@/components/charts/pie-chart-active"
<PieChartActive />
import SwiftUI

struct PieActiveExample: View {
  var body: some View {
    PieChartActive()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.PieChartActive

@Composable
fun PieActiveExample() {
    PieChartActive()
}

Donut Text

A donut with the total number of users displayed in the center of the ring.

components/charts/pie-chart-donut-text.tsx
"use client"

import { Pie, PieChart } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,

A donut with the total shown in its center, so readers get the overall number and the breakdown in one glance. Prefer it over the plain donut when the total is the headline.

Replace chartData and the category entries in chartConfig; the center total is summed from the data. Change the caption under the number to your unit, and adjust innerRadius if a longer number needs more room. The center text lets pointer events through, so slice tooltips still work.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-donut-text

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-donut-text

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartDonutText } from "@/components/charts/pie-chart-donut-text"
<PieChartDonutText />
Web

Web preview

uniwind/components/charts/pie-chart-donut-text.tsx
swift/Charts/PieChartDonutText.swift
kotlin/charts/PieChartDonutText.kt

A PieChart donut with small gaps and rounded slice corners. chartData holds one record per device with a users count. The total is summed from chartData and drawn as Text layered over the ring. Pressing a slice shows a tooltip.

Replace chartData with your records; the center total recalculates from it. Update the users caption and chartConfig labels and colors to match. The component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-donut-text

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-donut-text
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-donut-text

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-donut-text --platform swift
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-donut-text

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-donut-text --platform kotlin

The CLI also adds what it builds on: Card, Chart, Text.

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartDonutText } from "@/components/charts/pie-chart-donut-text"
<PieChartDonutText />
import SwiftUI

struct PieDonutTextExample: View {
  var body: some View {
    PieChartDonutText()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.PieChartDonutText

@Composable
fun PieDonutTextExample() {
    PieChartDonutText()
}

Donut

A donut chart with a hollow center and small gaps between slices.

components/charts/pie-chart-donut.tsx
"use client"

import { Pie, PieChart } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,

A donut with a hollow center and small gaps between slices. It reads lighter than a full pie and leaves the center free for a label if you need one later.

Replace chartData and add a label and color for each category key to chartConfig. innerRadius and outerRadius set the ring thickness, and paddingAngle the gap between slices.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-donut

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-donut

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartDonut } from "@/components/charts/pie-chart-donut"
<PieChartDonut />
Web

Web preview

uniwind/components/charts/pie-chart-donut.tsx
swift/Charts/PieChartDonut.swift
kotlin/charts/PieChartDonut.kt

A PieChart whose Pie uses innerRadius to leave the middle empty and paddingAngle to space the slices. chartData holds one record per device with a users count. Pressing a slice shows a tooltip.

Replace chartData with your records and keep dataKey and nameKey in step with your field names. Add one entry per slice to chartConfig with its label and color; the component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-donut

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-donut
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-donut

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-donut --platform swift
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-donut

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-donut --platform kotlin

The CLI also adds what it builds on: Card, Chart.

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartDonut } from "@/components/charts/pie-chart-donut"
<PieChartDonut />
import SwiftUI

struct PieDonutExample: View {
  var body: some View {
    PieChartDonut()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.PieChartDonut

@Composable
fun PieDonutExample() {
    PieChartDonut()
}

Half

A semicircular gauge-style pie showing battery share by device, with a caption under the arc.

components/charts/pie-chart-half.tsx
"use client"

import { Pie, PieChart } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,

A semicircular donut that reads like a gauge, with a figure and caption tucked under the arc. Use it in compact cards where a full circle takes too much height.

Replace chartData with your categories and their shares, and add each key to chartConfig. The tooltip appends a percent sign, so change its formatter if your values aren't percentages. The figure and caption under the arc are static text. The arc's size depends on the container height, so check the fit if you change it.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-half

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-half

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartHalf } from "@/components/charts/pie-chart-half"
<PieChartHalf />
Web

Web preview

uniwind/components/charts/pie-chart-half.tsx
swift/Charts/PieChartHalf.swift
kotlin/charts/PieChartHalf.kt

A PieChart drawn from 180 to 0 degrees, with rounded, spaced slices. chartData holds a percentage share per device. A centered Text shows the 100% total, and the tooltip uses a custom formatter to print each share as a percentage.

Replace chartData with your shares and update chartConfig and the caption under the arc. The component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-half

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-half
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-half

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-half --platform swift
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-half

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-half --platform kotlin

The CLI also adds what it builds on: Card, Chart, Text.

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartHalf } from "@/components/charts/pie-chart-half"
<PieChartHalf />
import SwiftUI

struct PieHalfExample: View {
  var body: some View {
    PieChartHalf()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.PieChartHalf

@Composable
fun PieHalfExample() {
    PieChartHalf()
}

Interactive

A storage breakdown donut with a device switch, hover-linked list and lifted slices, plus a linear usage bar.

components/charts/pie-chart-interactive.tsx
"use client"

import * as React from "react"
import { Pie, PieChart, Sector } from "recharts"

import { Card, CardContent, CardHeader } from "@/components/ui/card"
import { type ChartConfig, ChartContainer } from "@/components/ui/chart"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"

type Device = "phone" | "cloud"

type Kind =
  | "apps"
  | "photos"
  | "system"
  | "backups"

A storage breakdown with a Phone and Cloud switch, a stacked usage bar, a donut whose hovered slice lifts out and a list linked to it. The center shows the used total or the hovered category, and the slices morph when you switch devices. Use it as a reference for a rich part-to-whole view with linked controls.

Replace STORAGE with your sources, each with a total and the size of every category, list the categories in KINDS and add a label and color for each to chartConfig. Free space is computed from the total, and each source adds a toggle. Hovering the slices, the bar or the list highlights a category, but list rows aren't focusable, so keyboard users only get the totals. The center readout is a live region, and the morph is skipped when reduced motion is preferred.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-interactive

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-interactive

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartInteractive } from "@/components/charts/pie-chart-interactive"
<PieChartInteractive />
Web

Web preview

uniwind/components/charts/pie-chart-interactive.tsx
swift/Charts/PieChartInteractive.swift
kotlin/charts/PieChartInteractive.kt

A Card with a ToggleGroup that switches between phone and cloud storage, a stacked usage bar, a PieChart donut and a list of categories. Sizes come from the STORAGE record, and free space is the total minus what is used. Pressing a slice or a list row selects that category: its slice lifts outward, other segments in the bar dim, and the center text shows its size and share. Pressing it again returns to total used. The donut sets isAnimationActive={false} and draws without the enter animation.

Replace STORAGE with your devices, totals and per-category sizes, and keep KINDS, chartConfig and SWATCH in sync when adding categories. The component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-interactive

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-interactive
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-interactive

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-interactive --platform swift
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-interactive

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-interactive --platform kotlin

The CLI also adds what it builds on: Card, Chart, Text, Toggle Group.

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartInteractive } from "@/components/charts/pie-chart-interactive"
<PieChartInteractive />
import SwiftUI

struct PieInteractiveExample: View {
  var body: some View {
    PieChartInteractive()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.PieChartInteractive

@Composable
fun PieInteractiveExample() {
    PieChartInteractive()
}

Label

A pie with each category name drawn outside its slice and joined by a leader line.

components/charts/pie-chart-label.tsx
"use client"

import { Pie, PieChart } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,

A pie with each category name printed outside its slice and connected by a leader line. Use it when readers shouldn't have to match colors against a separate legend.

Replace chartData and the category entries in chartConfig; labels read their text from the config. Change what the custom label renderer returns to print values or percentages, and shrink outerRadius if long names get clipped. Outside labels collide when slices are thin, so keep the category count low.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-label

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-label

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartLabel } from "@/components/charts/pie-chart-label"
<PieChartLabel />
Web

Web preview

uniwind/components/charts/pie-chart-label.tsx
swift/Charts/PieChartLabel.swift
kotlin/charts/PieChartLabel.kt

A PieChart with a smaller radius to leave room for labels. chartData holds one record per device with a users count. The label callback reads each slice name from chartConfig, and labelLine draws the connector. Pressing a slice shows a tooltip.

Replace chartData with your records and keep dataKey and nameKey in step with your field names. Add one entry per slice to chartConfig with its label and color; the component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-label

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-label
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-label

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-label --platform swift
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-label

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-label --platform kotlin

The CLI also adds what it builds on: Card, Chart.

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartLabel } from "@/components/charts/pie-chart-label"
<PieChartLabel />
import SwiftUI

struct PieLabelExample: View {
  var body: some View {
    PieChartLabel()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.PieChartLabel

@Composable
fun PieLabelExample() {
    PieChartLabel()
}

Legend

A donut with a legend beneath it that lists every category and its color.

components/charts/pie-chart-legend.tsx
"use client"

import { Pie, PieChart } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartLegend,
  ChartLegendContent,

A donut with a legend underneath listing every category and its color. Pick it when a chart has enough slices that labels around the ring would get crowded.

Replace chartData and add a label and color for each category to chartConfig; the legend reads both from there. Keep nameKey on the legend content set to your category field so the names resolve.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-legend

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-legend

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartLegend } from "@/components/charts/pie-chart-legend"
<PieChartLegend />
Web

Web preview

uniwind/components/charts/pie-chart-legend.tsx
swift/Charts/PieChartLegend.swift
kotlin/charts/PieChartLegend.kt

A PieChart donut with a ChartLegend that lists every slice from chartConfig. chartData holds one record per device with a users count. Pressing a slice shows a tooltip.

Replace chartData with your records and keep dataKey and nameKey in step with your field names. Add one entry per slice to chartConfig with its label and color; the component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-legend

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-legend
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-legend

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-legend --platform swift
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-legend

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-legend --platform kotlin

The CLI also adds what it builds on: Card, Chart.

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartLegend } from "@/components/charts/pie-chart-legend"
<PieChartLegend />
import SwiftUI

struct PieLegendExample: View {
  var body: some View {
    PieChartLegend()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.PieChartLegend

@Composable
fun PieLegendExample() {
    PieChartLegend()
}

Nested

Two concentric pies: an inner ring of grouped totals surrounded by an outer ring of individual categories.

components/charts/pie-chart-nested.tsx
"use client"

import { Pie, PieChart } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,

Two concentric rings: a lighter inner pie of group totals surrounded by an outer ring of individual categories. Use it for two-level breakdowns, such as product lines and the products within them.

Put the detailed records in chartData and the group totals in groups, with each group total equal to the sum of its categories. Order the outer categories so each group's members sit next to their inner slice. The demo groups reuse the Phone and Watch keys, so their tooltips read Phone and Watch; give each group its own key and label in chartConfig.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-nested

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-nested

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartNested } from "@/components/charts/pie-chart-nested"
<PieChartNested />
Web

Web preview

uniwind/components/charts/pie-chart-nested.tsx
swift/Charts/PieChartNested.swift
kotlin/charts/PieChartNested.kt

A PieChart with two Pie layers. The inner pie reads a groups array and is drawn at reduced opacity; the outer ring reads chartData, one record per device. Pressing a slice in either ring shows a tooltip.

Replace groups and chartData with your summary and detail records, and add each name to chartConfig with its label and color. The component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-nested

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-nested
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-nested

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-nested --platform swift
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-nested

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-nested --platform kotlin

The CLI also adds what it builds on: Card, Chart.

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartNested } from "@/components/charts/pie-chart-nested"
<PieChartNested />
import SwiftUI

struct PieNestedExample: View {
  var body: some View {
    PieChartNested()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.PieChartNested

@Composable
fun PieNestedExample() {
    PieChartNested()
}

Separated

A donut whose slices are pulled apart with wide gaps and rounded corners.

components/charts/pie-chart-separated.tsx
"use client"

import { Pie, PieChart } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,

A donut whose slices are pushed apart with wide gaps and rounded corners, giving each segment a tile-like look. Choose it for a softer, more decorative style than the standard donut.

Replace chartData and add each category to chartConfig. paddingAngle sets the spacing and cornerRadius the rounding; large values squeeze thin slices, so this style suits data without tiny values.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-separated

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-separated

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartSeparated } from "@/components/charts/pie-chart-separated"
<PieChartSeparated />
Web

Web preview

uniwind/components/charts/pie-chart-separated.tsx
swift/Charts/PieChartSeparated.swift
kotlin/charts/PieChartSeparated.kt

A PieChart donut with paddingAngle and cornerRadius set so each slice stands apart. chartData holds one record per device with a users count. Pressing a slice shows a tooltip.

Replace chartData with your records and keep dataKey and nameKey in step with your field names. Add one entry per slice to chartConfig with its label and color; the component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pie-chart-separated

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-separated
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-separated

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-separated --platform swift
$ pnpm dlx shadcn@latest add @esuiss/pie-chart-separated

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts pie-chart-separated --platform kotlin

The CLI also adds what it builds on: Card, Chart.

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { PieChartSeparated } from "@/components/charts/pie-chart-separated"
<PieChartSeparated />
import SwiftUI

struct PieSeparatedExample: View {
  var body: some View {
    PieChartSeparated()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.PieChartSeparated

@Composable
fun PieSeparatedExample() {
    PieChartSeparated()
}
NextRadar ChartPreviousLine Chart

On this page

  1. 01Default
  2. 02Active
  3. 03Donut Text
  4. 04Donut
  5. 05Half
  6. 06Interactive
  7. 07Label
  8. 08Legend
  9. 09Nested
  10. 10Separated