仔细阅读源代码后,我尝试了以下操作,该操作有效但在控制台中生成警告。
const myTheme = createMuiTheme({
overrides: {
MuiSwitch: {
checked: {
"& + $bar": {
opacity: 1.0,
backgroundColor: "rgb(129, 171, 134)" // Light green, aka #74d77f
}
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
我得到的错误/警告是:
Warning: Material-UI: the `MuiSwitch` component increases the CSS specificity of the `checked` internal state.
You can not override it like this:
{
"checked": {
"& + $bar": {
"opacity": 1,
"backgroundColor": "rgb(129, 171, 134)"
}
}
}
Instead, you need to use the $ruleName syntax:
{ …Run Code Online (Sandbox Code Playgroud)