Skip to main content
Urbicon UI

DonutChartbeta

Donut or pie chart for part-to-whole composition, with an optional center total.

Playground

stable: 59 (60%)beta: 27 (28%)experimental: 12 (12%)98Components
  • stable
  • beta
  • experimental
Donut chart: 3 segments, total 98
SegmentValueShare
stable5960%
beta2728%
experimental1212%
<script lang="ts">
  import { DonutChart } from '@urbicon-ui/blocks';

  const data = [
    { label: 'stable', value: 59 },
    { label: 'beta', value: 27 },
    { label: 'experimental', value: 12 }
  ];
</script>

<DonutChart
  {data}
  padAngle={1}
  showTotal
/>

01 Examples

Donut with center total

showTotal prints the summed value in the hole; totalLabel captions it. Ideal for a KPI surrounded by its breakdown.
Direct: 45 (45%)Referral: 30 (30%)Organic: 18 (18%)Social: 7 (7%)100Visits
  • Direct
  • Referral
  • Organic
  • Social
Donut chart: 4 segments, total 100
SegmentValueShare
Direct4545%
Referral3030%
Organic1818%
Social77%
<DonutChart data={sources} showTotal totalLabel="Visits" />

Pie

Set innerRadiusRatio to 0 for a solid pie when the hole isn't needed.
Direct: 45 (45%)Referral: 30 (30%)Organic: 18 (18%)Social: 7 (7%)
  • Direct
  • Referral
  • Organic
  • Social
Donut chart: 4 segments, total 100
SegmentValueShare
Direct4545%
Referral3030%
Organic1818%
Social77%
<DonutChart innerRadiusRatio={0} data={sources} />

Formatted values

formatValue controls the center total, the per-slice tooltips, and the data-table fallback.
Rent: €1,200 (46%)Food: €600 (23%)Transport: €300 (12%)Savings: €500 (19%)€2,600Monthly
  • Rent
  • Food
  • Transport
  • Savings
Donut chart: 4 segments, total €2,600
SegmentValueShare
Rent€1,20046%
Food€60023%
Transport€30012%
Savings€50019%
<DonutChart data={budget} formatValue={eur} showTotal totalLabel="Monthly" padAngle={1.5} />

02 Customization

Custom slice colors

Each slice accepts an explicit color; omitted slices fall back to the categorical palette.
Done: 72 (72%)In progress: 20 (20%)Blocked: 8 (8%)100
  • Done
  • In progress
  • Blocked
Donut chart: 3 segments, total 100
SegmentValueShare
Done7272%
In progress2020%
Blocked88%
<DonutChart
  showTotal
  data={[
    { label: 'Done', value: 72, color: 'var(--color-success)' },
    { label: 'In progress', value: 20, color: 'var(--color-primary)' },
    { label: 'Blocked', value: 8, color: 'var(--color-danger)' }
  ]}
/>

03 Accessibility

SVG with role="img"

The SVG carries role="img" with a generated aria-label noting the segment count and total.

Data-table fallback

A visually hidden table lists each segment with its value and computed share, so the composition is fully available to screen readers.

Per-segment tooltips

Each arc includes a native <title> with its label, value, and percentage share.

04 API Reference

15 props
15 props 1 required
Prop
Type
Default
Description

05 Types

Local type definitions used by this component.

4 types
Name
Kind
Category
Used by
Description

06 Installation

Import

import { DonutChart } from '@urbicon-ui/blocks';