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/ChartsLegend';
// or
import { ContinuousColorLegend } from '@mui/x-charts-pro';
// or
import { ContinuousColorLegend } from '@mui/x-charts-premium/ChartsLegend';
// or
import { ContinuousColorLegend } from '@mui/x-charts-premium';Learn about the difference by reading this guide on minimizing bundle size.
Props of the native component are also available.
| Name | Type | Default | Description |
|---|---|---|---|
| axisDirection | 'x' | 'y' | 'z' | 'z' | The axis direction containing the color configuration to represent. |
| axisId | number | string | The first axis item. | The id of the axis item with the color configuration to represent. |
| classes | Partial | - | 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. |
| gradientId | string | auto-generated id | The id for the gradient to use.
If not provided, it will use the generated gradient from the axis configuration.
The |
| labelPosition | 'end' | 'extremes' | 'start' | 'end' | Where to position the labels relative to the gradient. |
| maxLabel | func | 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. |
| minLabel | func | string | formattedValue | The label to display at the minimum side of the gradient. Can either be a string, or a function. |
| reverse | bool | false | If |
| slotProps | ChartsLegendSlotProps | {} | The props used for each component slot. |
| slots | ChartsLegendSlots | {} | Overridable component slots. See Slots API below for more details. |
| tabIndex | number | - | |
| thickness | number | 12 | The thickness of the gradient |
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.
| Slot name | Class name | Default component | Description |
|---|---|---|---|
| legend | ChartsLegend | Custom rendering of the legend. |
These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.
| Class name | Rule name | Description |
|---|---|---|
| .MuiContinuousColorLegend-end | end | Styles applied to the legend with the labels after the gradient. |
| .MuiContinuousColorLegend-extremes | extremes | Styles applied to the legend with the labels on the extremes of the gradient. |
| .MuiContinuousColorLegend-gradient | gradient | Styles applied to the list item with the gradient. |
| .MuiContinuousColorLegend-horizontal | horizontal | Styles applied to the legend in row layout. |
| .MuiContinuousColorLegend-label | label | Styles applied to the series label. |
| .MuiContinuousColorLegend-maxLabel | maxLabel | Styles applied to the list item that renders the `maxLabel`. |
| .MuiContinuousColorLegend-minLabel | minLabel | Styles applied to the list item that renders the `minLabel`. |
| .MuiContinuousColorLegend-root | root | Styles applied to the root element. |
| .MuiContinuousColorLegend-start | start | Styles applied to the legend with the labels before the gradient. |
| .MuiContinuousColorLegend-vertical | vertical | Styles applied to the legend in column layout. |
You can override the style of the component using one of these customization options:
- With a global class name.
- With a rule name as part of the component's
styleOverridesproperty in a custom theme.
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.