I am trying to customize the disabled Step color on Material UI Steppers
The default color is Blue (Enabled) + Grey (Disabled). But I am looking to change this to something like so:
But I don't seem to able to find any hook into the Icon
section of the StepLabel
. I already tried applying the CSS to the IconContainer
, but the specificity is not sufficient.
My code is available here: https://codesandbox.io/s/0102v4z1op
TIA!
The color of the stepper bullets can't be changed using any props directly. We can change it by using a theme.
Wrap your stepper in a Theme Widget. It will change the index color of the stepper as well as the CONTINUE button color to orange(Set the color as per your own requirement). Save this answer.
<Stepper
activeStep={activeStep}
orientation="vertical"
connector={false}
>
{steps.map((label, index) => {
return (
<Step key={label} className={classes.step} classes={{ completed: classes.completed }}>
<StepButton icon={<DeleteIcon className={classes.xiconRoot}/>} completed={index === 2}>
<StepLabel
classes={{
iconContainer: classes.iconContainer
}}
>
{label}
</StepLabel>
</StepButton>
</Step>
);
})}
</Stepper>
Similary to completed
in classes
applied to Step
You can apply the following to override different states. https://material-ui.com/api/step/#css-api
Complete example snippet https://codesandbox.io/s/vn8m2rqol3
I did it like this:
<StepLabel
classes={{
alternativeLabel: classes.alternativeLabel,
labelContainer: classes.labelContainer
}}
StepIconProps={{
classes: {
root: classes.step,
completed: classes.completed,
active: classes.active,
disabled: classes.disabled
}
}}
>
{this.state.labels[label - 1]}
</StepLabel>
And then in the classes I've defined them as follows:
step: {
"&$completed": {
color: "lightgreen"
},
"&$active": {
color: "pink"
},
"&$disabled: {
color: "red"
},
},
alternativeLabel: {},
active: {}, //needed so that the &$active tag works
completed: {},
disabled: {},
labelContainer: {
"&$alternativeLabel": {
marginTop: 0
},
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With