GitHub
Core
Glass
Brutal
Humanist

Donut Chart
Pro

A circular chart similar to a pie chart, with a central cut-out, used to show proportional data.

Donut Chart Playground

Donut Chart Playground
Preview
Code
Google Ads
375 (37.5%)
Direct Traffic
208 (20.8%)
Organic Search
167 (16.7%)
Referral Links
125 (12.5%)
Social Media
83 (8.3%)
Email Campaigns
42 (4.2%)
Controls
Segments:
2
3
4
5
6
Track:
Legend:
Center Content:

Semi Donut Chart Playground

Semi Donut Chart Playground
Preview
Code
Mobile
416 (43.1%)
Desktop
250 (25.9%)
Tablet
83 (8.6%)
Smart TV
83 (8.6%)
Wearable
83 (8.6%)
Other
50 (5.2%)
Controls
Segments:
1
2
3
4
5
6
Track:
Legend:
Center Content:

Installation

You can add the donut chart component to your project manually:

1

Install the following dependencies:

npm install class-variance-authority clsx tailwind-merge recharts
2

Copy and paste the following code into your project.

Loading...
3

Update the import paths to match your project setup.

Update the import aliases (e.g. @/components, @/utils) in the copied files to match your project's path configuration.

Basic Usage

A simple donut chart with auto-generated legend:

import { VersaDonutChart } from '@versaui/ui/components/Charts';

const data = [
  { name: 'Revenue', value: 375 },
  { name: 'Expenses', value: 208 },
  { name: 'Profit', value: 167 },
];

<VersaDonutChart data={data} />

Multi-Segment

Supports up to 6 segments using brand and state color tokens:

<VersaDonutChart
  data={[
    { name: 'Segment 1', value: 375 },
    { name: 'Segment 2', value: 208 },
    { name: 'Segment 3', value: 167 },
    { name: 'Segment 4', value: 125 },
    { name: 'Segment 5', value: 83 },
    { name: 'Segment 6', value: 42 },
  ]}
/>

Explicit Colors

Assign specific color tokens to segments:

<VersaDonutChart
  data={[
    { name: 'Active', value: 800, color: 'primary' },
    { name: 'Errors', value: 120, color: 'error' },
    { name: 'Warnings', value: 80, color: 'warning' },
  ]}
/>

Center Content

Render custom content in the donut center using the centerContent render prop:

<VersaDonutChart
  data={data}
  centerContent={(total) => (
    <div className="text-center">
      <div className="text-h5">{total.toLocaleString()}</div>
      <div className="text-b5 text-subtle">Total</div>
    </div>
  )}
/>

Semi Donut Chart

A half-circle donut for gauges and compact distribution views:

import { VersaSemiDonutChart } from '@versaui/ui/components/Charts';

<VersaSemiDonutChart
  data={[
    { name: 'Completed', value: 416 },
    { name: 'Remaining', value: 250 },
  ]}
/>

Track Mode

Show a gray background track for gauge-style "out of 100" displays:

<VersaSemiDonutChart
  data={[
    { name: 'Progress', value: 667 },
  ]}
  showTrack
/>

Legend Configuration

{/* Hide legend */}
<VersaDonutChart data={data} legend={false} />

{/* Legend auto-switches to stacked for ≤3 segments, wrapped grid for 4+ */}

Loading & Empty States

{/* Loading state */}
<ChartContainer size="large" loading>
  <VersaDonutChart data={[]} />
</ChartContainer>

{/* Empty state — shows "No data available" message */}
<VersaDonutChart data={[]} />

Accessibility

  • Screen readers: Chart uses proper ARIA roles and labels
  • Keyboard navigation: Legend items are focusable and toggleable with Enter/Space
  • Reduced motion: Animations disabled when prefers-reduced-motion: reduce is set
  • Tooltips: Announced via role="tooltip" with proper semantics

VersaDonutChart Props

PropTypeDefaultDescription
dataDonutSegmentData[]Required. Array of segment objects with name and value.
size'large' | 'medium''large'Chart size variant.
legendbooleantrueShow auto-generated card-style legend.
showTrackbooleanfalseShow a gray background track arc (full 360°).
totalnumberExplicit total for 100% of the track. When provided and greater than the data sum, segments fill proportionally. Used with showTrack.
centerContent(total: number) => ReactNodeRender prop for custom center content.
classNamestring''Additional CSS classes.

VersaSemiDonutChart Props

PropTypeDefaultDescription
dataDonutSegmentData[]Required. Array of segment objects with name and value.
size'large' | 'medium''large'Chart size variant.
legendbooleantrueShow auto-generated card-style legend.
showTrackbooleanfalseShow gray background track (gauge mode).
totalnumberExplicit total for 100% of the track. When provided and greater than the data sum, segments fill proportionally. Used with showTrack.
centerContent(total: number) => ReactNodeRender prop for custom center content.
classNamestring''Additional CSS classes.

DonutSegmentData

PropTypeDefaultDescription
namestringRequired. Segment label shown in legend and tooltip.
valuenumberRequired. Numeric value for this segment.
color'primary' | 'secondary' | 'tertiary' | 'quaternary' | 'error' | 'warning'autoColor token. Auto-assigned from palette if omitted.

On this page