Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable IconButton ripple effect in Material UI?

I am having a AppBar with IconButton in it. While hovering the button it shows a oval hover in it . I tried to disable it by giving

disableFocusRipple={true}

But it doesnt works.Please help me with that.

Here i am sharing the image of the hover

like image 253
Dhanush Kumar Sivaji Avatar asked Mar 06 '20 13:03

Dhanush Kumar Sivaji


People also ask

How do I disable the ripple effect in material UI button?

For some reason none of the disableRipple properties has worked for me, but I was able to disable ripple effect on an IconButton by just making its hover background colour transparent.

How do I get rid of the ripple effect in MUI?

While searching the solution for same question in case of react material UI, if someone stumbles upon this page like me, Quick way to remove ripple from a React MaterialUI Button component is to add "disableRipple" attribute.


2 Answers

You might use the property disableRipple. if true it will disable the ripple effect. disableFocusRipple only works when disableRipple is true. But you have a price on that. You loose some state styles. Take a look at the API docs. https://material-ui.com/api/button/

like image 87
Gaspar Teixeira Avatar answered Nov 14 '22 23:11

Gaspar Teixeira


For some reason none of the disableRipple properties has worked for me, but I was able to disable ripple effect on an IconButton by just making its hover background colour transparent.

Code:

<IconButton className={classes.disableRipple} aria-label="View">
  <InfoIcon/>
</IconButton>

Then just style it like so (or any other way you want to style it, can be inline):

const useStyles = makeStyles(() => ({
  disableRipple: {
    '&:hover': {
      backgroundColor: 'transparent',
    },
  },
}));
like image 22
lidkxx Avatar answered Nov 14 '22 22:11

lidkxx