cssreactjsmaterial-uijss

Put Border Color React Material Theme


How do you put material color theme in border like this code below

border: '2px solid (theme.palette.primary.main)',

Solution

  • You need to use template literals.

     border: `2px solid ${theme.palette.primary.main}`
    

    How to access the theme object depends on the rest of your code. In a function component this could look like this:

    const useStyles = makeStyles(theme => ({
      /// your style declarations
    })
    

    Please refer to the documentation for other examples.