Playground
Installation
Sunburst comes with WunderUI Core and Pro, in the package from your plan. See the plans.
The charts live in their own entry point: import the chart, its card and its hooks from @wunderui/react/charts, not from @wunderui/react.
Then import what you need:
import {
SunburstChart,
SunburstChartProps,
SunburstChartVariant,
} from "@wunderui/react/charts"Then use it:
import { SunburstChart } from "@wunderui/react/charts"
const data = {
name: "Revenue",
children: [
{ name: "Software", children: [{ name: "Core", value: 340 }, { name: "Pro", value: 260 }] },
{ name: "Services", children: [{ name: "Support", value: 150 }] },
],
}
export function RevenueMix() {
return <SunburstChart data={data} centerLabel="revenue" label="Revenue by product line" />
}Expected result: You see two rings, the outer one split into three segments, with the total in the centre.
When to use
Use Sunburst for
- A hierarchy as rings, where each ring is a level
- The total in the centre, and the value of the part you hover
- Nested circles (circle packing) for a hierarchy without a total
Use something else for
- Treemap for many small leaves that need more room
- Pie Chart for one level of shares
- Network Chart for an organisation chart as a tree
- Radial Chart for progress against a goal
States
Loading, empty and error keep the chart's size, so the card never jumps. Add a retry handler and the error state offers a Try again button.
Keyboard interactions
The plot is focusable. Arrow keys walk the parts and the live region reads each with its path, value and share of the top-level total.
- TaborShiftTab
- Moves focus to the plot and away from it. The plot is one tab stop; so is every legend badge.
- ArrowRightorArrowLeft
- Moves to the next or previous part. The tooltip follows, and a live region announces the one you are on. The first press starts at the first one (Left: the last one).
- HomeorEnd
- Jumps to the first or last part.
- Escape
- Clears the active point.
- EnterorSpace
- On a legend badge of a ChartCard: switches its series off or on. The last visible series stays on.
Behavior and motion
What the chart does on its own and what the page decides.
- Data
- The data is a hierarchy tree. Segments are sized by value and coloured by their top-level group.
- Centre
- The sunburst shows the total, or the value of the hovered part, with a label under it (default total). Circle packing has no centre.
- Frame
- The frame is square and hugs its card. You can set its height (default 360).
- Loading, empty and error
- The chart keeps its size while loading, empty or failed, so the card never jumps. Add a retry handler to show a Try again button on error.
- Legend
- A ChartCard shows the series as badges. With two or more series each badge switches its series off, but the last visible one stays on.
- Size
- The chart fills the width of its container, and you set the plot height. Text never scales, so labels keep their size at every width.
Motion
The enter sequence and the hover follow the library's motion tokens.
- Unfold
- Ring segments unfold from the centre when the chart first comes into view, after loading and when the data changes. You can turn it off.
- Hover
- The centre counts to the value of the hovered part.
- Reduced motion
- With reduced motion the chart appears at once. The tooltip, the crosshair and every state still work.
Anatomy
A sunburst shows a hierarchy as rings, one per level, or as nested circles (circle packing). The centre counts to the value of the hovered part, and the frame is square and hugs its card.
Revenue mix
| label | Value |
|---|---|
| Software | $1010k |
| Services | $350k |
| Hardware | $240k |
| Core | $340k |
| Pro | $260k |
| Enterprise | $410k |
| Onboarding | $120k |
| Training | $80k |
| Support | $150k |
| Devices | $180k |
| Accessories | $60k |
Takes a hierarchy tree as its data. You can set the text under the centre value (default total), fade groups and set the frame height (default 360).
- data-slot="chart-plot"
The focusable region. Arrow keys walk the parts and the live region reads each with its path, value and share of the top-level total, like Hardware › Devices: 180, 12.3% of the total.
- data-slot="chart-marks"
Ring segments that unfold from the centre, sized by value, in the colour of their top-level group. Circle packing draws a circle per node and nests the children inside.
The total, or the value of the hovered part, with a label under it. Only the sunburst has a centre, circle packing does not.
- data-slot="chart-tooltip"
The path of the part with its value and its share of the total.
- data-slot="chart-message"
A muted ring on the sunburst and a muted disc on circle packing, under the shimmer.
A hidden table of every node with its path and value.
Best practices
- Do
Keep it to three levels. Outer rings of many small segments can't be labelled or hovered.
- Do
Set the centre label to what the total counts, such as orders or GB, so the centre number isn't read as a percentage.
- Do
Use circle packing when the nesting matters more than the proportions, and keep leaf values positive.
- Don’t
Don't compare segments on different rings by angle. A child's angle is relative to its parent, so use the table for exact values.
- Don’t
Don't use it for a flat list. A PieChart or BarChart is simpler and easier to read.
API reference
One table for SunburstChart, listing every prop. The ChartCard around it has its own props, and the chart also works without one.
Takes a hierarchy tree as its data. You can set the text under the centre value (default total), fade groups and set the frame height (default 360).
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("sunburst")The full library index for assistants is at /llms.txt.