1 回答

TA貢獻1836條經驗 獲得超13個贊
const ColoredSwitch = withStyles({
? switchBase: {
? ? "&.Mui-checked": {
? ? ? color: (props) => props.customchecked
? ? }
? },
? checked: {},
? track: {}
})((props) => {
? const { classes, ...other } = props;
? return <Switch classes={{ switchBase: classes.switchBase }} {...other} />;
});
您也可以使用makeStyles
const useStyles = makeStyles({
? switchBaseChecked: {
? ? "&.Mui-checked": {
? ? ? color: (props) => props.color
? ? }
? }
});
export default function Switches() {
? const props = { color: "green" };
? const classes = useStyles(props);
? return (
? ? <Switch
? ? ? color="primary"
? ? ? classes={{
? ? ? ? checked: classes.switchBaseChecked
? ? ? }}
? ? />
? );
}
添加回答
舉報