@@ -137,46 +137,28 @@ const SwitchSwitchBase = experimentalStyled(
137137 } ,
138138 } ) ,
139139 ( { theme, styleProps } ) => ( {
140- /* Styles applied to the internal SwitchBase component's root element if `color="primary "`. */
141- ...( styleProps . color === 'primary ' && {
140+ /* Styles applied to the internal SwitchBase component element unless `color="default "`. */
141+ ...( styleProps . color !== 'default ' && {
142142 '&.Mui-checked' : {
143- color : theme . palette . primary . main ,
143+ color : theme . palette [ styleProps . color ] . main ,
144144 '&:hover' : {
145- backgroundColor : alpha ( theme . palette . primary . main , theme . palette . action . hoverOpacity ) ,
145+ backgroundColor : alpha (
146+ theme . palette [ styleProps . color ] . main ,
147+ theme . palette . action . hoverOpacity ,
148+ ) ,
146149 '@media (hover: none)' : {
147150 backgroundColor : 'transparent' ,
148151 } ,
149152 } ,
150- } ,
151- '&.Mui-disabled' : {
152- color :
153- theme . palette . mode === 'light'
154- ? lighten ( theme . palette . secondary . main , 0.62 )
155- : darken ( theme . palette . secondary . main , 0.55 ) ,
156- } ,
157- [ `&.Mui-checked + .${ switchClasses . track } ` ] : {
158- backgroundColor : theme . palette . primary . main ,
159- } ,
160- } ) ,
161- /* Styles applied to the internal SwitchBase component's root element if `color="secondary"`. */
162- ...( styleProps . color === 'secondary' && {
163- '&.Mui-checked' : {
164- color : theme . palette . secondary . main ,
165- '&:hover' : {
166- backgroundColor : alpha ( theme . palette . secondary . main , theme . palette . action . hoverOpacity ) ,
167- '@media (hover: none)' : {
168- backgroundColor : 'transparent' ,
169- } ,
153+ '&.Mui-disabled' : {
154+ color :
155+ theme . palette . mode === 'light'
156+ ? lighten ( theme . palette [ styleProps . color ] . main , 0.62 )
157+ : darken ( theme . palette [ styleProps . color ] . main , 0.55 ) ,
170158 } ,
171159 } ,
172- '&.Mui-disabled' : {
173- color :
174- theme . palette . mode === 'light'
175- ? lighten ( theme . palette . secondary . main , 0.62 )
176- : darken ( theme . palette . secondary . main , 0.55 ) ,
177- } ,
178160 [ `&.Mui-checked + .${ switchClasses . track } ` ] : {
179- backgroundColor : theme . palette . secondary . main ,
161+ backgroundColor : theme . palette [ styleProps . color ] . main ,
180162 } ,
181163 } ) ,
182164 } ) ,
0 commit comments