I’m using switch component from MUI, I want to toggle the styling between two colors
<Switch
color={dataType === "expenses" ? "error" : "secondary"}
onChange={handleOnSwitch}
checked={dataType === "expenses"}
/>
The problem is the color is applied only when the condition is true and the switch is checked , while if it’s unchecked it will be the default gray color stylings
I’ll appreciate any help.
I was trying to change the color of MUI switch component but the unchecked state remain always on default gray color
2
Answers
Here I am writing a sample code for you. You can get the look you want by changing the styled codes here.
You just need to use style props like that