60

I added the css hover property to disable the button's hover effect, but it seems not work for my case, how should I fix this?

import Button from 'material-ui/Button'
import styled from 'styled-components'

const StyledButton = styled(Button)`
  &:hover {
    background: none;
  }
`
export const SubmitButton = ({ onClick }) => {
  return (
    <StyledButton
      variant="raised"
      onClick={onClick}>
      login
    </StyledButton>
  )
}
JGallardo
  • 11,074
  • 10
  • 82
  • 96
ccd
  • 5,788
  • 10
  • 46
  • 96

9 Answers9

65

You can solve this problem by adding an inline style

export const SubmitButton = ({ onClick }) => {
  return (
    <StyledButton
      variant="raised"
      onClick={onClick}
      style={{ backgroundColor: 'transparent' }} >
      login
    </StyledButton>
  )
}
The Lazy Coder
  • 11,560
  • 4
  • 51
  • 69
ccd
  • 5,788
  • 10
  • 46
  • 96
50

Try setting it to the same color as the background:

root = {
    backgroundColor: "#FFF"
    "&:hover": {
        //you want this to be the same as the backgroundColor above
        backgroundColor: "#FFF"
    }
}
IvanS95
  • 5,364
  • 4
  • 24
  • 62
Nishant Mehta
  • 612
  • 4
  • 11
27

this is solution for v5 if anyone needs it

         <IconButton
            disableElevation
            disableRipple
            size="small"
            sx={{
              ml: 1,
              "&.MuiButtonBase-root:hover": {
                bgcolor: "transparent"
              }
            }}
          >

          </IconButton>
Said Pc
  • 565
  • 7
  • 13
  • Btw: This also is the way to go for the MUI Radio component because it inherits ButtonBase API. – Andru Sep 19 '22 at 15:05
9

You can try setting the background of the button as none

button: {    
    '&:hover': {
        background: 'none',
    },
}
d-_-b
  • 21,536
  • 40
  • 150
  • 256
Saranya Jena
  • 91
  • 1
  • 2
0

If you used the origin Button component with className instead, you could have added disableRipple to the button like that. <Button disableRipple>

Maya Liberman
  • 328
  • 3
  • 5
0

You can just override it via a styled component:

const StyledButton = styled(Button)`
    &:hover {
      background-color: transparent;
    }
`;
Robin Wieruch
  • 14,900
  • 10
  • 82
  • 107
0

This should work

const StyledButton = styled(Button)`
  &&.MuiButton-root {
    &:hover {
      background: none;
    }
  }
`
0

We can able to disable material-ui button hover effect in following way by adding these two details in the component In my case I did for Switch button.

disableRipple

style={{ backgroundColor: "transparent" }}

import React from "react";
import FormControlLabel from "@material-ui/core/FormControlLabel";
import Switch from "@material-ui/core/Switch";
import { withStyles } from "@material-ui/core/styles";

const styles = {
  
};

class SwitchLabels extends React.Component {
  state = {
    checked: true
  };

  handleChange = (event) => {
    this.setState({ checked: event.target.checked });
  };

  render() {
    return (
      <FormControlLabel
        control={
          <Switch
            classes={this.props.classes}
            checked={this.state.checked}
            onChange={this.handleChange}
            disableElevation
            disableRipple
            style={{ backgroundColor: "transparent" }}
            value="checked"
            color="primary"
          />
        }
        labelPlacement="start"
        label={this.state.checked ? "On" : 'Off'}
      />
    );
  }
}

export default withStyles(styles)(SwitchLabels);
KARTHIKEYAN.A
  • 18,210
  • 6
  • 124
  • 133
-1

Work for me

 <Button 
    sx={{
      color:'#000000', 
      background:'rgba(0, 0, 0, 0.065)', 
      width:'84px', 
      height:'51px', 
      boxShadow: '0px 0px 4px 0px #00000040',
      fontSize:'20px',
      '&:hover': {
           background:'rgba(0, 0, 0, 0.065)'
      },
    }} 
    variant="contained">
    +50$
   </Button>