Skip to content

ContinuousColorLegend API

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

Demos

Import

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

Learn about the difference by reading this guide on minimizing bundle size.

Props

Props of the native component are also available.

NameTypeDefaultDescription
axisDirection'x'
| 'y'
| 'z'
'z'

The axis direction containing the color configuration to represent.

axisIdnumber
| string
The first axis item.

The id of the axis item with the color configuration to represent.

classesobject-

Override or extend the styles applied to the component.

See CSS classes API below for more details.

direction'horizontal'
| 'vertical'
'horizontal'

The direction of the legend layout.

gradientIdstringauto-generated id

The id for the gradient to use. If not provided, it will use the generated gradient from the axis configuration. The gradientId will be used as fill="url(#gradientId)".

labelPosition'start'
| 'end'
| 'extremes'
'end'

Where to position the labels relative to the gradient.

maxLabelfunc
| string
formattedValue

The label to display at the maximum side of the gradient. Can either be a string, or a function. If not defined, the formatted maximal value is display.

minLabelfunc
| string
formattedValue

The label to display at the minimum side of the gradient. Can either be a string, or a function.

reverseboolfalse

If true, the gradient and labels will be reversed.

rotateGradientbool-

If provided, the gradient will be rotated by 90deg. Useful for linear gradients that are not in the correct orientation.

thicknessnumber12

The thickness of the gradient

The ref is forwarded to the root element.

Theme default props

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

CSS classes

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

Class nameRule nameDescription
.MuiContinuousColorLegend-endendStyles applied to the legend with the labels after the gradient.
.MuiContinuousColorLegend-extremesextremesStyles applied to the legend with the labels on the extremes of the gradient.
.MuiContinuousColorLegend-gradientgradientStyles applied to the list item with the gradient.
.MuiContinuousColorLegend-horizontalhorizontalStyles applied to the legend in row layout.
.MuiContinuousColorLegend-labellabelStyles applied to the series label.
.MuiContinuousColorLegend-maxLabelmaxLabelStyles applied to the list item that renders the maxLabel.
.MuiContinuousColorLegend-minLabelminLabelStyles applied to the list item that renders the minLabel.
.MuiContinuousColorLegend-rootrootStyles applied to the root element.
.MuiContinuousColorLegend-startstartStyles applied to the legend with the labels before the gradient.
.MuiContinuousColorLegend-verticalverticalStyles applied to the legend in column layout.

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

Source code

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