Skip to content
NewYour data: charts, lists and meters that take your records
<hf-donut>Custom elementData

Donut

Donut chart that sweeps in clockwise; hovering or arrowing to a segment pops it outward and rolls its share into the centre.

View as Markdown
<hf-donut>

Your data

Pass your Label:value segments as data (and total for the centre). Without it the chart shows invented usage shares. See Your data.

Playground

Change a prop and the component updates. Props marked live animate to the new value; the others rebuild the element.

Loading <hf-donut>
Props
datalive
labellive
totallive
<HfDonut
  data="Code:42,Writing:23,Analysis:18,Other:17"
  label="Conversations"
  total="1,284"
/>

Installation

pnpm dlx shadcn@latest add @lumesec/hf-donut
First timeRegister the @lumesec registry once, or install by URL

Adds @lumesec to your components.json:

pnpm dlx shadcn@latest registry add @lumesec=https://elements.lumesec.ai/r/{name}.json

Or skip the setup and install by URL:

npx shadcn@latest add https://elements.lumesec.ai/r/hf-donut.json

Usage

import { HfDonut } from "@/components/lumesec/hf-donut";

export function Example() {
  return (
    <HfDonut data="Code:42,Writing:23,Analysis:18,Other:17" total="1,284" label="Conversations" />
  );
}

Behaviour

Sweeps in clockwise. Hovering a segment or legend row pops it outward and rolls its share into the middle; arrow keys work too.

API reference

Attributes

dataReact propdataTypestringDefaultCode:42,Writing:23,Analysis:18,Other:17

Comma-separated Label:value pairs, split at the last colon. Values are relative and shown as rounded percentages of their sum; a missing or negative value counts as 0. Observed: a change rebuilds the chart and it sweeps in again.

labelReact proplabelTypestringDefaultUsage by task

Text in the centre and the start of the aria-label. Observed.

totalReact proptotalTypestring

Text in the centre when no segment is focused. Defaults to the sum of the values. Observed.

Properties

data (read-only)TypeArray<{ label: string, v: number }>

Segments parsed from the attribute.

Keyboard

KeysAction
ArrowRight / ArrowDownFocus the next segment, wrapping.
ArrowLeft / ArrowUpFocus the previous segment, wrapping.

Accessibility

  • The canvas has role="img", tabindex="0" and an aria-label listing each segment percentage.
  • The centre text is not a live region.
  • Legend rows react to pointer hover only. Moving focus away from the canvas clears the highlight.
  • Reduced motion: the donut appears without the sweep and the centre text swaps without rolling; the segment pop still eases.

Theming

The element reads your shadcn theme tokens through its shadow root, so light and dark follow your theme. The accent comes from --lumesec. See Theming.

This component reads --foreground, --lumesec and --muted-foreground.

To restyle only LumeSec elements, set the matching --ui-* overrides: --ui-accent, --ui-fg and --ui-muted.

Notes

  • Colours cycle through accent, ok, warn, danger and muted; a sixth segment reuses the accent colour.
  • All attributes are observed.
  • The chart is fixed at 176 × 176 px.

Was this page helpful?