Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

A pie chart with no separator for React

A browser pie whose slices meet with no stroke between them. Colors and the tooltip match the simple pie.

The slices sit flush against each other. Nothing is drawn in the cracks. Colors still come from the chart config, and the tooltip still names the browser.

Use it for a flatter pie, when the gaps read as decoration. Keep the stroke if similar colors need a boundary. For exact counts, use a Table. In React, Base UI does not remove the gaps. You turn the stroke off, and you pass the rows.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
Use email insteadNo credit card

Anatomy

Chart anatomy: container, grid, axis, bar, tooltip, legend

Usage

<div className="w-full max-w-xl rounded-md border bg-background p-4">
  <ChartContainer
    className="mx-auto aspect-square max-h-[250px]"
    config={chartConfig}
  >
    <PieChart>
      <ChartTooltip
        content={<ChartTooltipContent hideLabel />}
        cursor={false}
      />
      <Pie data={chartData} dataKey="visitors" nameKey="browser" stroke="0" />
    </PieChart>
  </ChartContainer>
</div>

FAQ

How are the gaps between slices removed?

Pie sets stroke to "0". dataKey is visitors and nameKey is browser, so the slices still split by visitor count and keep their browser names.

How does each slice get its color?

Each row sets fill to a variable such as var(--color-chrome). config maps chrome, safari, firefox, edge, and other to --chart-1 through --chart-5, with labels Chrome, Safari, Firefox, Edge, and Other.

What does the tooltip show?

ChartTooltipContent sets hideLabel, and cursor is false. The slice name comes from nameKey browser, looked up in config, and the value is visitors.

Which counts are in the pie?

Chrome is 275, Safari 200, Firefox 187, Edge 173, and Other 90. The data keys are lowercase. config supplies the words in the tooltip.

Why is the chart square?

ChartContainer uses mx-auto aspect-square max-h-[250px]. The outer frame is w-full max-w-xl with a border and padding.

What is the visitors entry in config for?

visitors has the label Visitors and no color. Slice colors live on the browser keys. Nothing in this file prints a label on the slices themselves.

API Reference

Chart

Sets config={chartConfig} and hideLabel. The rest is on the Chart page.