Sunburst Chart
Hierarchical rings. Default and Motion variants.
Examples
Installation
Default is a ready-made wrapper from the registry. Motion is the composable engine at @cronus-ui/ui/charts (peer visx + motion).
npx cronus-ui add sunburst-chart
import { SunburstChart } from "@cronus-ui/ui";
Usage
import { SunburstChart, SunburstSegment, SunburstCenter, SunburstLabels, buildArcs } from "@cronus-ui/ui/charts";const { arcs } = buildArcs(tree);<SunburstChart data={tree} size={360}>{arcs.map((arc) => <SunburstSegment index={arc.arcIndex} key={arc.id} />)}<SunburstCenter /><SunburstLabels /></SunburstChart>
Components
Motion API — compose these under the chart root. Default wrapper props are in Default API below.
SunburstChart
Hierarchical rings with drill-down focus and hover grow.
| Prop | Type | Default | Description |
|---|---|---|---|
data* | SunburstNode | — | Root node with nested children. |
size | number | 520 | Pixel size. |
focusId | string | — | Controlled drill-down node id. |
onFocusChange | (focusId: string) => void | — | Focus callback. |
hoveredIndex | number | null | — | Controlled hover (arc index). |
hoverPop | number | 8 | Grow distance on hover. |
SunburstSegment
One arc. Click drills in; hover grows the ring.
| Prop | Type | Default | Description |
|---|---|---|---|
index* | number | — | Index in the arcs array. |
color | string | — | Override color. |
fill | string | — | Pattern/gradient url. |
SunburstCenter
Hub disc. Click zooms out to the parent focus.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Circle class. |
SunburstLabels
Arc labels with a halo stroke so they stay readable on any fill.
| Prop | Type | Default | Description |
|---|---|---|---|
fontSize | number | 11 | Label size. |
fill | string | var(--chart-label) | Label fill. |
SunburstHint
Hover trail (parent › child). Accepts a render prop.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | ((ctx) => ReactNode) | — | Custom hint. |
Legend
Composable side legend. Map `LegendItem` (marker, label, value, optional progress) over `items`. Share `hoveredIndex` with the chart for bidirectional highlight.
| Prop | Type | Default | Description |
|---|---|---|---|
items* | LegendItemData[] | — | Label, value, color, optional maxValue. |
hoveredIndex | number | null | — | Controlled hover. |
onHoverChange | (index: number | null) => void | — | Hover callback. |
title | string | — | Heading above the list. |
children* | ReactElement | — | A single LegendItem template, cloned per item. |
Drill-down
Click a segment to focus that node. SunburstCenter zooms out. Drive focusId yourself, or use SunburstBreadcrumb with useSunburstBreadcrumbItems().
const { items, zoomTo } = useSunburstBreadcrumbItems();<SunburstBreadcrumb>{items.map((item) => (<button key={item.id} type="button" onClick={() => zoomTo(item.id)}>{item.label}</button>))}</SunburstBreadcrumb>
Data format
Leaves need `value`. Parents can omit it — the layout sums children.
type SunburstNode = {name: string;value?: number;color?: string;fill?: string;children?: SunburstNode[];};const tree: SunburstNode = {name: "All",children: [{ name: "Product", children: [{ name: "App", value: 28 }, { name: "API", value: 20 }] },{ name: "Services", value: 18 },],};
Theming
Motion charts read `--chart-*` aliases that map onto Cronus semantic tokens (`--cronus-chart-1`…`--cronus-chart-5`, `--cronus-border`, `--cronus-fg`, surfaces). Override the aliases or the tokens — never palette scales (`bg-zinc-900`). Default wrappers use `ChartConfig` with `var(--cronus-chart-*)` / `var(--cronus-primary)`. defaultSunburstColors cycles `--chart-1`…`--chart-5`. Nested rings fade with depth.
Full token reference: Theming.
Dependencies
Default needs the recharts peer. Motion needs visx (and sometimes d3) as optional peers — install only what this chart uses.
bun add recharts
bun add motion
Default API
Generated from the Default wrapper's exported types. Motion subcomponents are documented above.
SunburstChartProps
Extends HTMLAttributes<HTMLDivElement>
| Prop | Type | Default | Description |
|---|---|---|---|
data* | SunburstNode[] | — | — |