1

Currently I'm trying to apply a pseudo-selector using the material UI style prop object. Styles are currently applied with method with the exclusion of the pseudo element.

styles.jsx--

const SBoxMain = {
  display:"inline-block",
  margin:"0px 5px",
  hover: {backgroundColor: "yellow"}
}

Component.jsx--

<Box style={SBoxMain} id="Other" onClick={e => filterType("Other")}>
  <Box style={SBoxTile}>
    Other
  </Box>
</Box>

While above code does not throw any error, there is no pseudo element logic applied to the HTML. How would I implement logic for ::after and :hover respectively?

1 Answers1

0

pseudo selects can be used in conjunction with material ui classes.

content: {
display: "flex",
"&::before": {
  content: '""',
  boxShadow: "0 0 6px 1px #ccc"
},

To add pseudo-selectors to classes,just append "&" to the pseudo selector string.