DonutChart

Ring sweeps in segment by segment. Hover swells a segment and swaps the center. Charts.

Open playground
10,000
Visits
  • Direct42%
  • Search31%
  • Social18%
  • Email9%

About

DonutChart is a React component in the Charts category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { DonutChart } from "@ashutoshswamy/smoui" and set data, size, totalLabel among its 4 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { DonutChart } from "@ashutoshswamy/smoui";

<DonutChart data={[{ label: "Direct", value: 4200 }, { label: "Search", value: 3100 }]} totalLabel="Visits" />

Props 4

data

Segments. Colors are tones of the accent.

{ label: string; value: number }[]
size / thickness

Ring size and stroke in px.

numberdefault 168 / 18
totalLabel

Caption under the total.

stringdefault "Total"
prefix / suffix

Wrap the value. Or pass `format` as a function.

string