Home > OS >  Change IconButton color
Change IconButton color

Time:01-23

I want to add a custom color to IconButton

      <IconButton variant='contained'>
        <StarBorderRoundedIcon color='red' />
      </IconButton>

and this is the output

enter image description here

The red color is not working.

CodePudding user response:

<IconButton variant='contained' style="background-color: red">
  <StarBorderRoundedIcon/>
</IconButton>

CodePudding user response:

Color property on the icon here refers to the theme color property so you can define colors as primary,success,action..You can use style property instead something like

<IconButton variant='contained'>
        <StarBorderRoundedIcon style={{color:'red'}} />
</IconButton>

Working demo

or you can use sx property

<IconButton variant='contained'>
            <StarBorderRoundedIcon sx={{color:'red'}} />
    </IconButton>
  • Related