Skip to content
Charts

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).

bash
npx cronus-ui add sunburst-chart
tsx
import { SunburstChart } from "@cronus-ui/ui";

Usage

tsx
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.

Skip SunburstChartProps props table
PropTypeDefaultDescription
data*
SunburstNodeRoot node with nested children.
size
number520Pixel size.
focusId
stringControlled drill-down node id.
onFocusChange
(focusId: string) => voidFocus callback.
hoveredIndex
number | nullControlled hover (arc index).
hoverPop
number8Grow distance on hover.

SunburstSegment

One arc. Click drills in; hover grows the ring.

Skip SunburstSegmentProps props table
PropTypeDefaultDescription
index*
numberIndex in the arcs array.
color
stringOverride color.
fill
stringPattern/gradient url.

SunburstCenter

Hub disc. Click zooms out to the parent focus.

Skip SunburstCenterProps props table
PropTypeDefaultDescription
className
stringCircle class.

SunburstBreadcrumb

Drill-down path. useSunburstBreadcrumbItems() returns items + zoomTo.

Skip SunburstBreadcrumbProps props table
PropTypeDefaultDescription
children*
ReactNodeUsually mapped buttons from useSunburstBreadcrumbItems.

SunburstLabels

Arc labels with a halo stroke so they stay readable on any fill.

Skip SunburstLabelsProps props table
PropTypeDefaultDescription
fontSize
number11Label size.
fill
stringvar(--chart-label)Label fill.

SunburstHint

Hover trail (parent › child). Accepts a render prop.

Skip SunburstHintProps props table
PropTypeDefaultDescription
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.

Skip LegendProps props table
PropTypeDefaultDescription
items*
LegendItemData[]Label, value, color, optional maxValue.
hoveredIndex
number | nullControlled hover.
onHoverChange
(index: number | null) => voidHover callback.
title
stringHeading above the list.
children*
ReactElementA 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().

tsx
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.

ts
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.

bash
bun add recharts
bash
bun add motion

Default API

Generated from the Default wrapper's exported types. Motion subcomponents are documented above.

SunburstChartProps

Extends HTMLAttributes<HTMLDivElement>

Skip SunburstChartProps props table
PropTypeDefaultDescription
data*
SunburstNode[]