[object Promise]

# ChartsLegend API

## Demos

For examples and details on the usage of this React component, visit the component demo pages:

- [Charts - Legend](/x/react-charts/legend/)

## Import

```jsx
import { ChartsLegend } from '@mui/x-charts/ChartsLegend';
// or
import { ChartsLegend } from '@mui/x-charts';
// or
import { ChartsLegend } from '@mui/x-charts-pro';
// or
import { ChartsLegend } from '@mui/x-charts-premium';
```

## Props

| Name | Type | Default | Required | Description |
|------|------|---------|----------|-------------|
| classes | `object` | - | No | Override or extend the styles applied to the component. |
| direction | `'horizontal' \| 'vertical'` | - | No |  |
| onItemClick | `function(event: React.MouseEvent<HTMLButtonElement, MouseEvent>, legendItem: SeriesLegendItemContext, index: number) => void` | - | No |  |
| slotProps | `object` | `{}` | No |  |
| slots | `object` | `{}` | No |  |
| sx | `Array<func \| object \| bool> \| func \| object` | - | No | The system prop that allows defining system overrides as well as additional CSS styles. |
| toggleVisibilityOnClick | `bool` | `false` | No |  |

> **Note**: The `ref` is forwarded to the root element (HTMLUListElement).

> Any other props supplied will be provided to the root element (native element).

## Theme default props

You can use `MuiChartsLegend` to change the default props of this component with the theme.

## Slots

| Name | Default | Class | Description |
|------|---------|-------|-------------|
| legend | `ChartsLegend` | - | Custom rendering of the legend. |

## CSS

### Rule name

| Global class | Rule name | Description |
|--------------|-----------|-------------|
| - | hidden | Styles applied to hidden items. |
| - | horizontal | Styles applied to the legend in row layout. |
| - | item | Styles applied to the list item around each series in the legend. |
| - | label | Styles applied to the series label. |
| - | mark | Styles applied to series mark element. |
| - | root | Styles applied to the root element. |
| - | series | Styles applied to a series element. |
| - | vertical | Styles applied to the legend in column layout. |

## Source code

If you did not find the information on this page, consider having a look at the implementation of the component for more detail.

- [/packages/x-charts/src/ChartsLegend/ChartsLegend.tsx](https://github.com/mui/material-ui/tree/HEAD/packages/x-charts/src/ChartsLegend/ChartsLegend.tsx)

# ChartsText API

## Demos

For examples and details on the usage of this React component, visit the component demo pages:

- [Charts - Axis](/x/react-charts/axis/)
- [Charts - Legend](/x/react-charts/legend/)

## Import

```jsx
import { ChartsText } from '@mui/x-charts/ChartsText';
// or
import { ChartsText } from '@mui/x-charts';
// or
import { ChartsText } from '@mui/x-charts-pro';
// or
import { ChartsText } from '@mui/x-charts-premium';
```

## Props

| Name | Type | Default | Required | Description |
|------|------|---------|----------|-------------|
| text | `string` | - | Yes |  |
| lineHeight | `number` | - | No |  |
| needsComputation | `bool` | `false` | No |  |
| style | `object` | - | No |  |

> **Note**: The `ref` is forwarded to the root element.

## Source code

If you did not find the information on this page, consider having a look at the implementation of the component for more detail.

- [/packages/x-charts/src/ChartsText/ChartsText.tsx](https://github.com/mui/material-ui/tree/HEAD/packages/x-charts/src/ChartsText/ChartsText.tsx)

# ContinuousColorLegend API

## Demos

For examples and details on the usage of this React component, visit the component demo pages:

- [Charts - Legend](/x/react-charts/legend/)

## Import

```jsx
import { ContinuousColorLegend } from '@mui/x-charts/ChartsLegend';
// or
import { ContinuousColorLegend } from '@mui/x-charts';
// or
import { ContinuousColorLegend } from '@mui/x-charts-pro';
// or
import { ContinuousColorLegend } from '@mui/x-charts-premium';
```

## Props

| Name | Type | Default | Required | Description |
|------|------|---------|----------|-------------|
| axisDirection | `'x' \| 'y' \| 'z'` | `'z'` | No |  |
| axisId | `number \| string` | `The first axis item.` | No |  |
| classes | `object` | - | No | Override or extend the styles applied to the component. |
| direction | `'horizontal' \| 'vertical'` | `'horizontal'` | No |  |
| gradientId | `string` | `auto-generated id` | No |  |
| labelPosition | `'start' \| 'end' \| 'extremes'` | `'end'` | No |  |
| maxLabel | `func \| string` | `formattedValue` | No |  |
| minLabel | `func \| string` | `formattedValue` | No |  |
| reverse | `bool` | `false` | No |  |
| rotateGradient | `bool` | - | No |  |
| sx | `Array<func \| object \| bool> \| func \| object` | - | No | The system prop that allows defining system overrides as well as additional CSS styles. |
| thickness | `number` | `12` | No |  |

> **Note**: The `ref` is forwarded to the root element (HTMLUListElement).

> Any other props supplied will be provided to the root element (native element).

## Theme default props

You can use `MuiContinuousColorLegend` to change the default props of this component with the theme.

## CSS

### Rule name

| Global class | Rule name | Description |
|--------------|-----------|-------------|
| - | end | Styles applied to the legend with the labels after the gradient. |
| - | extremes | Styles applied to the legend with the labels on the extremes of the gradient. |
| - | gradient | Styles applied to the list item with the gradient. |
| - | horizontal | Styles applied to the legend in row layout. |
| - | label | Styles applied to the series label. |
| - | maxLabel | Styles applied to the list item that renders the `maxLabel`. |
| - | minLabel | Styles applied to the list item that renders the `minLabel`. |
| - | root | Styles applied to the root element. |
| - | start | Styles applied to the legend with the labels before the gradient. |
| - | vertical | Styles applied to the legend in column layout. |

## Source code

If you did not find the information on this page, consider having a look at the implementation of the component for more detail.

- [/packages/x-charts/src/ChartsLegend/ContinuousColorLegend.tsx](https://github.com/mui/material-ui/tree/HEAD/packages/x-charts/src/ChartsLegend/ContinuousColorLegend.tsx)

# PiecewiseColorLegend API

## Demos

For examples and details on the usage of this React component, visit the component demo pages:

- [Charts - Legend](/x/react-charts/legend/)

## Import

```jsx
import { PiecewiseColorLegend } from '@mui/x-charts/ChartsLegend';
// or
import { PiecewiseColorLegend } from '@mui/x-charts';
// or
import { PiecewiseColorLegend } from '@mui/x-charts-pro';
// or
import { PiecewiseColorLegend } from '@mui/x-charts-premium';
```

## Props

| Name | Type | Default | Required | Description |
|------|------|---------|----------|-------------|
| axisDirection | `'x' \| 'y' \| 'z'` | `'z'` | No |  |
| axisId | `number \| string` | `The first axis item.` | No |  |
| classes | `object` | - | No | Override or extend the styles applied to the component. |
| direction | `'horizontal' \| 'vertical'` | `'horizontal'` | No |  |
| labelFormatter | `function(params: PiecewiseLabelFormatterParams) => string \| null` | - | No |  |
| labelPosition | `'start' \| 'end' \| 'extremes' \| 'inline-start' \| 'inline-end'` | `'extremes'` | No |  |
| markType | `'square' \| 'circle' \| 'line'` | `'square'` | No |  |
| onItemClick | `function(event: React.MouseEvent<HTMLButtonElement, MouseEvent>, legendItem: PiecewiseColorLegendItemContext, index: number) => void` | - | No |  |
| sx | `Array<func \| object \| bool> \| func \| object` | - | No | The system prop that allows defining system overrides as well as additional CSS styles. |

> **Note**: The `ref` is forwarded to the root element (HTMLUListElement).

> Any other props supplied will be provided to the root element (native element).

## Theme default props

You can use `MuiPiecewiseColorLegend` to change the default props of this component with the theme.

## CSS

### Rule name

| Global class | Rule name | Description |
|--------------|-----------|-------------|
| - | end | Styles applied to the legend with the labels after the color marks. |
| - | extremes | Styles applied to the legend with the labels on the extremes of the color marks. |
| - | horizontal | Styles applied to the legend in row layout. |
| - | inlineEnd | Styles applied to the legend with the labels inlined after the color marks. |
| - | inlineStart | Styles applied to the legend with the labels inlined before the color marks. |
| - | item | Styles applied to the list items. |
| - | label | Styles applied to the series label. |
| - | mark | Styles applied to the marks. |
| - | maxLabel | Styles applied to the list item that renders the `maxLabel`. |
| - | minLabel | Styles applied to the list item that renders the `minLabel`. |
| - | root | Styles applied to the root element. |
| - | start | Styles applied to the legend with the labels before the color marks. |
| - | vertical | Styles applied to the legend in column layout. |

## Source code

If you did not find the information on this page, consider having a look at the implementation of the component for more detail.

- [/packages/x-charts/src/ChartsLegend/PiecewiseColorLegend.tsx](https://github.com/mui/material-ui/tree/HEAD/packages/x-charts/src/ChartsLegend/PiecewiseColorLegend.tsx)