Home > Blockchain >  React: UseStyles with CSS Class Name Wildcard Prefix
React: UseStyles with CSS Class Name Wildcard Prefix

Time:08-30

How do I apply class name wildcard styles with UseStyles? I want to apply this CSS, with all class names prefixes with MuiFormHelperText.

  const useStyles = makeStyles({
    helperText: {
      '& .MuiFormHelperText-root': {
        height: '0',
        marginTop: '0',
      },
    },
  });

Currently, in execution the actual css Class Name is MuiFormHelperText-root"]': { height: '0', marginTop: '0', }, }, })

CodePudding user response:

Try this

const useStyles = makeStyles({
  helperText: {
    '*[class^="MuiFormHelperText-root"]': {
      height: '0',
      marginTop: '0',
    },
  },
})

OR

const useStyles = makeStyles({
  helperText: {
    '&[class^="MuiFormHelperText-root"]': {
      height: '0',
      marginTop: '0',
    },
  },
})
  • Related