Skip to content

DefaultChartsLegend API

API reference docs for the React DefaultChartsLegend component. Learn about the props, CSS, and other APIs of this exported module.

Component demos

Import

import { DefaultChartsLegend } from '@mui/x-charts/ChartsLegend';
// or
import { DefaultChartsLegend } from '@mui/x-charts';
Learn about the difference by reading this guide on minimizing bundle size.

Props

classesRequired

Override or extend the styles applied to the component.

See CSS API below for more details.

Type:object


directionRequired

The direction of the legend layout. The default depends on the chart.

Type:'column'
| 'row'


hidden

Set to true to hide the legend.

Type:bool

Default:false


itemGap

Space between two legend items (in px).

Type:number

Default:10


itemMarkHeight

Height of the item mark (in px).

Type:number

Default:20


itemMarkWidth

Width of the item mark (in px).

Type:number

Default:20


labelStyle

Style applied to legend labels.

Type:object

Default:theme.typography.subtitle1


markGap

Space between the mark and the label (in px).

Type:number

Default:5


padding

Legend padding (in px). Can either be a single number, or an object with top, left, bottom, right properties.

Type:number
| { bottom?: number, left?: number, right?: number, top?: number }

Default:10


The component cannot hold a ref.

CSS classes

These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.

.MuiDefaultChartsLegend-mark

Rule name:mark


.MuiDefaultChartsLegend-root

Rule name:root


.MuiDefaultChartsLegend-series

Rule name:series



You can override the style of the component using one of these customization options: