Skip to content

Commit b0c279f

Browse files
[charts] Add item class to list item around each series in legend (#18411)
1 parent ea2a758 commit b0c279f

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

docs/pages/x/api/charts/charts-legend.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939
"description": "Styles applied to the legend in row layout.",
4040
"isGlobal": false
4141
},
42+
{
43+
"key": "item",
44+
"className": "MuiChartsLegend-item",
45+
"description": "Styles applied to the list item around each series in the legend.",
46+
"isGlobal": false
47+
},
4248
{
4349
"key": "label",
4450
"className": "MuiChartsLegend-label",

docs/translations/api-docs/charts/charts-legend/charts-legend.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
"description": "Styles applied to {{nodeName}}.",
2222
"nodeName": "the legend in row layout"
2323
},
24+
"item": {
25+
"description": "Styles applied to {{nodeName}}.",
26+
"nodeName": "the list item around each series in the legend"
27+
},
2428
"label": { "description": "Styles applied to {{nodeName}}.", "nodeName": "the series label" },
2529
"mark": { "description": "Styles applied to {{nodeName}}.", "nodeName": "series mark element" },
2630
"root": { "description": "Styles applied to the root element." },

packages/x-charts/src/ChartsLegend/ChartsLegend.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ const ChartsLegend = consumeSlots(
107107
>
108108
{data.items.map((item, i) => {
109109
return (
110-
<li key={item.id}>
110+
<li key={item.id} className={classes?.item}>
111111
<Element
112112
className={classes?.series}
113113
role={onItemClick ? 'button' : undefined}

packages/x-charts/src/ChartsLegend/chartsLegendClasses.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import type { ChartsLegendSlotExtension } from './chartsLegend.types';
77
export interface ChartsLegendClasses {
88
/** Styles applied to the root element. */
99
root: string;
10+
/** Styles applied to the list item around each series in the legend. */
11+
item: string;
1012
/** Styles applied to a series element. */
1113
series: string;
1214
/** Styles applied to series mark element. */
@@ -27,6 +29,7 @@ export const useUtilityClasses = (props: ChartsLegendProps & ChartsLegendSlotExt
2729
const { classes, direction } = props;
2830
const slots = {
2931
root: ['root', direction],
32+
item: ['item'],
3033
mark: ['mark'],
3134
label: ['label'],
3235
series: ['series'],
@@ -37,6 +40,7 @@ export const useUtilityClasses = (props: ChartsLegendProps & ChartsLegendSlotExt
3740

3841
export const legendClasses: ChartsLegendClasses = generateUtilityClasses('MuiChartsLegend', [
3942
'root',
43+
'item',
4044
'series',
4145
'mark',
4246
'label',

0 commit comments

Comments
 (0)