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 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 | object | - | 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 | 'start' | 'end' | 'extremes' | '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 |
rotateGradient | bool | - | If provided, the gradient will be rotated by 90deg. Useful for linear gradients that are not in the correct orientation. |
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.
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
styleOverrides
property 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.