Material-ui: Can we please add props to remove/disable hover effect on <Iconbutton /> like as disableRipple

Created on 23 Apr 2018  路  2Comments  路  Source: mui-org/material-ui

The hover effect on Iconbutton is really unwelcome in my app. Please add some option to disabling it instead of making it permanent.

screenshot from 2018-04-23 11-30-05

cc : @oliviertassinari Thanks in advance

IconButton wontfix

Most helpful comment

@Anugraha123 The hover effect was added by @SebastianSchmidt in #10871. I don't think that it needs a specific property for disabling the behavior. However, you can proceeed as follow:

import React from "react";
import PropTypes from "prop-types";
import { withStyles } from "material-ui/styles";
import IconButton from "material-ui/IconButton";
import DeleteIcon from "@material-ui/icons/Delete";

const styles = theme => ({
  button: {
    "&:hover": {
      backgroundColor: "transparent"
    }
  }
});

function IconButtons(props) {
  const { classes } = props;
  return (
    <IconButton className={classes.button} aria-label="Delete">
      <DeleteIcon />
    </IconButton>
  );
}

IconButtons.propTypes = {
  classes: PropTypes.object.isRequired
};

export default withStyles(styles)(IconButtons);

https://codesandbox.io/s/m393r8rk5y

All 2 comments

@Anugraha123 The hover effect was added by @SebastianSchmidt in #10871. I don't think that it needs a specific property for disabling the behavior. However, you can proceeed as follow:

import React from "react";
import PropTypes from "prop-types";
import { withStyles } from "material-ui/styles";
import IconButton from "material-ui/IconButton";
import DeleteIcon from "@material-ui/icons/Delete";

const styles = theme => ({
  button: {
    "&:hover": {
      backgroundColor: "transparent"
    }
  }
});

function IconButtons(props) {
  const { classes } = props;
  return (
    <IconButton className={classes.button} aria-label="Delete">
      <DeleteIcon />
    </IconButton>
  );
}

IconButtons.propTypes = {
  classes: PropTypes.object.isRequired
};

export default withStyles(styles)(IconButtons);

https://codesandbox.io/s/m393r8rk5y

"transparent" did not work for me. I had to take a slightly different approach.

  ButtonUnclickable: {
    '&:hover': {
      backgroundColor: theme.palette.primary.main,
    }
  },

Was this page helpful?
0 / 5 - 0 ratings