score:1

Accepted answer

i'm not sure why your code didn't work, but i've found a workaround by specifying the switch input classname directly like this:

import switch, { switchclasses } from "@mui/material/switch";
import { createtheme, themeprovider } from "@mui/material/styles";

const theme = createtheme({
  components: {
    muiswitch: {
      styleoverrides: {
        root: {
          [`& .${switchclasses.input}`]: {
            position: "absolute"
          }
        },
        switchbase: {
          color: "red"
        }
      }
    }
  }
});

live demo

codesandbox demo


Related Query

More Query from same tag