Skip to content
synccn

Donut Chart

Share of a total with hover focus and a centre value.

Visitors by device

35,050Visitors
  • Desktop53%
  • Mobile36%
  • Tablet9%
  • Other2%

Installation

$ pnpm dlx shadcn@latest add @synccn/donut-chart

First time in this project? Connect synccn with one command.

Usage

import { DonutChart } from "@/components/ui/charts";<DonutChart data={[{ label: "Desktop", value: 60 }]} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

DonutChart

Donut chart with an interactive legend and the total in the middle. data: [{ label, value }]

  • datarequired
    ChartDatum[]

    Segments.

  • size
    number

    Default 200

    Diameter in pixels.

  • thickness
    number

    Default 26

    Ring thickness in pixels.

  • format
    (value: number) => React.ReactNode

    Default (v) => v

    Formats the centre value.

  • centerLabel
    string

    Default "Total"

    Caption under the total.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

npm packages

Accessibility

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: img, meter
  • ARIA attributes: aria-label, aria-pressed, aria-valuemax, aria-valuemin, aria-valuenow