# SunburstChart
Package: @mantine/charts
Import: import { SunburstChart } from '@mantine/charts';
Description: Sunburst chart component for hierarchical data

## Usage

`SunburstChart` is based on the [SunburstChart recharts component](https://recharts.github.io/en-US/api/SunburstChart).
It displays hierarchical data as concentric rings.
In this storage example, the inner ring shows folders and the outer ring shows their contents:

```tsx
// Demo.tsx
import { SunburstChart } from '@mantine/charts';
import { Stack, Text } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <Stack align="center">
      <Text fw={500}>Storage usage</Text>
      <SunburstChart data={data} withLegend valueFormatter={(value) => `${value} GB`} />
    </Stack>
  );
}

// data.ts
export const data = ${JSON.stringify(data, null, 2)};
```


## Data format

Each node has a `name`. Leaf nodes have a `value`.
Nodes with `children` show the sum of their children, or their own `value` if it is larger:

```tsx
export const data = [
  {
    name: 'Projects',
    color: 'blue.7',
    children: [
      { name: 'client-app', value: 30 },
      { name: 'website', value: 12 },
      { name: 'experiments', value: 6 },
    ],
  },
  {
    name: 'Photos',
    color: 'teal.7',
    children: [
      { name: 'travel', value: 20 },
      { name: 'family', value: 12 },
    ],
  },
];
```

## Nested data

Add another `children` array to show a deeper level.
This example expands project folders to reveal how much space their dependencies use:

```tsx
// Demo.tsx
import { SunburstChart } from '@mantine/charts';
import { Stack, Text } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <Stack align="center">
      <Text fw={500}>Project storage breakdown</Text>
      <SunburstChart data={data} withLegend valueFormatter={(value) => `${value} GB`} />
      <Text size="sm" c="dimmed" ta="center">
        client-app/node_modules uses 24 GB of the 48 GB in Projects
      </Text>
    </Stack>
  );
}

// data.ts
export const data = ${JSON.stringify(data, null, 2)};
```


## Legend

Set `withLegend` to display a legend for top-level nodes.
Hover over a legend item to highlight its branch:

```tsx
// Demo.tsx
import { SunburstChart } from '@mantine/charts';
import { data } from './data';

function Demo() {
  return (
    <SunburstChart
      data={data}
      valueFormatter={(value) => `${value} GB`}
       withLegend={true}
    />
  );
}

// data.ts
export const data = ${JSON.stringify(data, null, 2)};
```


## Legend position

The legend is displayed below the chart by default.
Set `legendProps={{ position: 'top' }}` to display it above the chart:

```tsx
// Demo.tsx
import { SunburstChart } from '@mantine/charts';
import { data } from './data';

function Demo() {
  return (
    <SunburstChart
      data={data}
      withLegend
      legendProps={{ position: 'top' }}
      valueFormatter={(value) => `${value} GB`}
    />
  );
}

// data.ts
export const data = ${JSON.stringify(data, null, 2)};
```


## Node color

`color` accepts theme colors and any valid CSS color.
Children inherit their parent's color unless they set their own, like `client-app` below.
Top-level nodes without `color` use a default palette:

```tsx
// Demo.tsx
import { SunburstChart } from '@mantine/charts';
import { data } from './data';

function Demo() {
  return <SunburstChart data={data} valueFormatter={(value) => `${value} GB`} />;
}

// data.ts
export const data = ${JSON.stringify(data, null, 2)};
```


## Stroke color

Use `strokeColor` to change the color of the stroke around each sector:

```tsx
// Demo.tsx
import { SunburstChart } from '@mantine/charts';
import { data } from './data';

function Demo() {
  return (
    <SunburstChart data={data} strokeColor="gray.3" valueFormatter={(value) => `${value} GB`} />
  );
}

// data.ts
export const data = ${JSON.stringify(data, null, 2)};
```


## Chart size

Use `size` prop to control the width and height of the chart:

```tsx
// Demo.tsx
import { SunburstChart } from '@mantine/charts';
import { data } from './data';

function Demo() {
  return (
    <SunburstChart
      data={data}
      size={400}
      maw="100%"
      miw={0}
      valueFormatter={(value) => `${value} GB`}
    />
  );
}

// data.ts
export const data = ${JSON.stringify(data, null, 2)};
```


## Gap

Use `gap` prop to control the spacing between sectors and rings:

```tsx
// Demo.tsx
import { SunburstChart } from '@mantine/charts';
import { data } from './data';

function Demo() {
  return <SunburstChart data={data} valueFormatter={(value) => `${value} GB`} gap={1} />;
}

// data.ts
export const data = ${JSON.stringify(data, null, 2)};
```


## Inner radius

Use `innerRadius` prop to control the size of the empty circle in the center of the chart:

```tsx
// Demo.tsx
import { SunburstChart } from '@mantine/charts';
import { data } from './data';

function Demo() {
  return <SunburstChart data={data} valueFormatter={(value) => `${value} GB`} innerRadius={50} />;
}

// data.ts
export const data = ${JSON.stringify(data, null, 2)};
```


## Start and end angle

Use `startAngle` and `endAngle` props to draw a part of the ring.
Angles are in degrees, `0` points to the right and angles grow counterclockwise.
Without `endAngle`, the chart draws a full circle from `startAngle`:

```tsx
// Demo.tsx
import { SunburstChart } from '@mantine/charts';
import { data } from './data';

function Demo() {
  return (
    <SunburstChart
      data={data}
      startAngle={180}
      endAngle={0}
      valueFormatter={(value) => `${value} GB`}
    />
  );
}

// data.ts
export const data = ${JSON.stringify(data, null, 2)};
```


## Labels

Set `withLabels` to display value labels inside sectors.
Labels that do not fit are hidden; increase `size` to give them more space.
This example shows sales by category and product:

```tsx
// Demo.tsx
import { SunburstChart } from '@mantine/charts';
import { Stack, Text } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <Stack align="center">
      <Text fw={500}>Sales by category · October 2026</Text>
      <SunburstChart data={data} withLabels withLegend valueFormatter={(value) => `$${value / 1000}k`} />
    </Stack>
  );
}

// data.ts
export const data = ${JSON.stringify(data, null, 2)};
```


## Value formatter

Use `valueFormatter` to format values in the tooltip and labels:

```tsx
// Demo.tsx
import { SunburstChart } from '@mantine/charts';
import { Stack, Text } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <Stack align="center">
      <Text fw={500}>Sales by category · October 2026</Text>
      <SunburstChart
        data={data}
        valueFormatter={(value) =>
          value.toLocaleString('en-US', {
            style: 'currency',
            currency: 'USD',
            maximumFractionDigits: 0,
          })
        }
      />
    </Stack>
  );
}

// data.ts
export const data = ${JSON.stringify(data, null, 2)};
```


## Disable tooltip

To disable the tooltip, set `withTooltip={false}`:

```tsx
// Demo.tsx
import { SunburstChart } from '@mantine/charts';
import { data } from './data';

function Demo() {
  return (
    <SunburstChart
      data={data}
      withTooltip={false}
      withLabels
      valueFormatter={(value) => `${value} GB`}
    />
  );
}

// data.ts
export const data = ${JSON.stringify(data, null, 2)};
```



#### Props

**SunburstChart props**

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| autoContrast | boolean | theme.autoContrast | Determines whether label color should be black or white depending on the sector fill to improve contrast |
| children | React.ReactNode | - | Additional elements rendered inside `SunburstChart` component |
| data | SunburstChartData[] | required | Data used to render chart |
| dataKey | string | 'value' | Key in data object for the value |
| endAngle | number | startAngle + 360 | Angle in degrees at which the chart should end |
| gap | number | 1 | Gap between sectors and rings in px |
| innerRadius | number | 50 | Controls the radius of the inner circle at the center of the chart |
| legendProps | HierarchyChartLegendOptions | - | Props passed down to recharts `Legend` component, supports top and bottom positions |
| size | number | 300 | Controls chart width and height |
| startAngle | number | 0 | Angle in degrees from which the chart should start |
| strokeColor | MantineColor | - | Controls color of the sectors stroke, by default depends on color scheme |
| sunburstChartProps | Partial<Omit<SunburstChartProps, "data" \| "ref" \| "startAngle" \| "dataKey" \| "endAngle" \| "innerRadius" \| "textOptions">> | - | Props passed down to recharts `SunburstChart` component |
| tooltipAnimationDuration | number | 0 | Tooltip animation duration in ms |
| tooltipProps | RechartsProps | - | Props passed down to `Tooltip` recharts component |
| valueFormatter | (value: number) => string | - | A function to format values inside the tooltip and labels |
| withLabels | boolean | false | Determines whether value labels are displayed inside each sector |
| withLegend | boolean | false | Determines whether the legend for top-level nodes should be displayed |
| withTooltip | boolean | true | Determines whether the tooltip should be displayed when a node is hovered |


#### Styles API

SunburstChart component supports Styles API. With Styles API, you can customize styles of any inner element. Follow the documentation to learn how to use CSS modules, CSS variables and inline styles to get full control over component styles.

**SunburstChart selectors**

| Selector | Static selector | Description |
|----------|----------------|-------------|
| root | .mantine-SunburstChart-root | Root element |
| chart | .mantine-SunburstChart-chart | Chart wrapper when the legend is displayed |
| legendWrapper | .mantine-SunburstChart-legendWrapper | Wrapper around the legend |
| legend | .mantine-SunburstChart-legend | Legend root element |
| legendItem | .mantine-SunburstChart-legendItem | Legend item representing a top-level node |
| legendItemColor | .mantine-SunburstChart-legendItemColor | Legend item color |
| legendItemName | .mantine-SunburstChart-legendItemName | Legend item name |
| tooltip | .mantine-SunburstChart-tooltip | Tooltip root element |
| tooltipBody | .mantine-SunburstChart-tooltipBody | Tooltip wrapper around all items |
| tooltipItem | .mantine-SunburstChart-tooltipItem | Tooltip item representing data series |
| tooltipItemBody | .mantine-SunburstChart-tooltipItemBody | Tooltip item wrapper around item color and name |
| tooltipItemColor | .mantine-SunburstChart-tooltipItemColor | Tooltip item color |
| tooltipItemName | .mantine-SunburstChart-tooltipItemName | Tooltip item name |
| tooltipItemData | .mantine-SunburstChart-tooltipItemData | Tooltip item data |
| tooltipLabel | .mantine-SunburstChart-tooltipLabel | Label of the tooltip |

**SunburstChart CSS variables**

| Selector | Variable | Description |
|----------|----------|-------------|
| root | --chart-stroke-color | Controls color of the chart segments stroke |
| root | --chart-size | Controls width and height of the chart |
