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*
SunburstNode—Root node with nested children.
size
number520Pixel size.
focusId
string—Controlled drill-down node id.
onFocusChange
(focusId: string) => void—Focus callback.
hoveredIndex
number | null—Controlled hover (arc index).
hoverPop
number8Grow distance on hover.

SunburstSegment

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

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

Skip SunburstCenterProps props table
PropTypeDefaultDescription
className
string—Circle class.

SunburstBreadcrumb

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

Skip SunburstBreadcrumbProps props table
PropTypeDefaultDescription
children*
ReactNode—Usually 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 | 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().

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

.cronus

The same component declared in Cronus. Emitted at build time from the audit fixtures — the kernel renders it as HTML with no React.

PortedParity: MatchGeometry 1/1Pixel diff 0 pxLogic 1/1Parity scoreboard
default.cronus
app "audit-fixtures" {
  port 5176
}

style {
  preset aurora
  theme dark
}

component SunburstChartDefault layout:inline style:sunburst-chart {
  label "Traffic"
  text "Desktop"
  text "Mobile"
}

page "/audit/sunburst-chart/default" type:custom {
  use SunburstChartDefault
}

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[]——
className
string—Additional class names merged onto the root.
children
ReactNode—Contents of the component.
id
string—DOM id of the root element.