Skip to content

Commit a728eb9

Browse files
Merge pull request #1563 from Rajesh-Nagarajan-11/fix-stepper
fix(Stepper): use slots API for custom step icons and fix alignment (MUI v9)
2 parents d611828 + a8e3017 commit a728eb9

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/custom/Stepper/index.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ function ColorlibStepIcon(props: ColorlibStepIconPropsI) {
112112
);
113113
}
114114

115+
const stepLabelSlots = {
116+
stepIcon: ColorlibStepIcon
117+
};
118+
115119
const CustomizedStepper: React.FC<CustomizedStepperPropsI> = ({
116120
stepLabels,
117121
activeStep,
@@ -122,6 +126,13 @@ const CustomizedStepper: React.FC<CustomizedStepperPropsI> = ({
122126
}) => {
123127
const theme = useTheme();
124128

129+
const stepLabelSlotProps = useMemo(
130+
() => ({
131+
stepIcon: { icons } as Partial<ColorlibStepIconPropsI>
132+
}),
133+
[icons]
134+
);
135+
125136
return (
126137
<Stack data-testid={testId}>
127138
<Stack
@@ -135,12 +146,14 @@ const CustomizedStepper: React.FC<CustomizedStepperPropsI> = ({
135146
activeStep={activeStep}
136147
connector={<ColorlibConnector />}
137148
data-testid="stepper-container"
149+
sx={{ flex: 1 }}
138150
>
139151
{stepLabels.map((label, index) => (
140152
<Step key={label} data-testid={`step-${index}`}>
141153
<StyledStepLabel
142154
data-testid={`step-label-${index}`}
143-
StepIconComponent={(props) => <ColorlibStepIcon {...props} icons={icons} />}
155+
slots={stepLabelSlots}
156+
slotProps={stepLabelSlotProps}
144157
>
145158
{label}
146159
</StyledStepLabel>

0 commit comments

Comments
 (0)