Material UI – Global checkbox focus styling (not locally)

后端 未结 2 585
遥遥无期
遥遥无期 2021-01-16 03:21

Trying to alter styling of checkbox when it is focused at a global level using Material-UI (react).

At the moment only default and hover styling is working:

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-16 03:41

    its either a problem with specificity or you just need to add the classes you made to your component

    const styles = {
      root: {
        '&$disabled': {
          color: 'white',
        },
      },
      disabled: {},
    };
    

    compiles to:

    .root-x.disable-x {
      color: white;
    }
    

    ⚠️ You need to apply the two generated class names (root & disabled) to the DOM to make it work.

    i get this from the documentaiton

    https://material-ui.com/customization/components/#use-rulename-to-reference-a-local-rule-within-the-same-style-sheet

提交回复
热议问题