score:1
Accepted answer
In order to remove the grey circle displaying in background on hover then you can use disableFocusRipple
& disableRipple
property in IconButton component and set style={{ backgroundColor: 'transparent' }}
.
Ex:
<IconButton
disableFocusRipple
disableRipple
style={{ backgroundColor: "transparent" }}
aria-label="twitter"
>
<TwitterIcon className={classes.twitter} />
</IconButton>
To change the color of icon on hover then use hover
selector.
Ex:
const useStyles = makeStyles({
twitter: {
"&:hover": {
color: "#00acee"
}
}
});
I've created a quick example to illustrate the solution in codesandbox:
https://codesandbox.io/s/elegant-ramanujan-wnj9fw?file=/index.js:948-961
score:0
Define a hook. Import makeStyle
from '@material-ui/core/styles'
.
const useStyles = makeStyle(() => ({
styleRed: {
'&:hover': {
backgroundColor: '#f00'
}
},
styleBlue: {
'&:hover': {
backgroundColor: '#00f'
}
}
}));
Then in your component:
// using our hook
const {styleRed, styleBlue} = useStyles();
// some more code
return (
<>
<IconButton aria-label="twitter" classes={styleRed}>
<TwitterIcon />
</IconButton>
<IconButton aria-label="facebook" classes={styleBlue}>
<FacebookIcon />
</IconButton>
</>
)
Source: stackoverflow.com
Related Query
- IconButton Hovering Effect on Material UI
- How to disable IconButton ripple effect in Material UI?
- Hover effect on IconButton in Material-UI
- Material UI IconButton onClick to increment or decrement values
- How can I show edit button in column cell while hovering over table row in Material UI Table?
- How to disable ripple effect on Material UI Input?
- Changing material ui IconButton hovered style doesn't work
- Material Design Components Toggle effect not working
- How to enlarge Card size on hovering over it in Material UI?
- Nesting buttons in Material UI: how to disable ripple effect of container button while clicking on a child button?
- How to implement transition effect for displaying underline on hovering a react router Link?
- how to disable the halo effect of pressing the thumb of the material ui slider?
- Hover effect happens on all articles, instead of just the one I'm hovering
- material ui buttons effect
- Selecting second child div while hovering on first child div in makeStyles Material UI
- Change Material UI IconButton Icon on click
- How to disable ripple effect on primary action in react material lists
- Clicking on IconButton from Material UI causing Errors with Ref?
- Material UI Slide component - how to disable Slide Effect based on component state
- Ripple effect opacity in React Material UI
- How to position Material UI badge near IconButton in ReactJS?
- Conditional rendering in React based on the onClick property of the IconButton component in Material UI
- Hi I am trying to add the material ui Iconbutton with input ref to upload the image its not working
- How to style components using makeStyles and still have lifecycle methods in Material UI?
- With useEffect, how can I skip applying an effect upon the initial render?
- How to add multiple classes in Material UI using the classes props?
- Material UI and Grid system
- How to enable file upload on React's Material UI simple input?
- How to apply custom animation effect @keyframes in MUI?
- Is there a way I can overwrite the colour the Material UI Icons npm package provides in React?
More Query from same tag
- How to convert timestamp firestore to date string and display in antd table
- Typescript React component with propTypes
- ReactJS: Sort e mapping on dynamic value
- Add Click event in array of element in single canvas
- How to remove the value before the cursor - React
- How to apply NavLink activeStyles to its child components
- setState when this got changed
- ReactJS what is the proper way to wait for prop to load to avoid crashing my page?
- Removing item from redux-stored list and redirect back to list - delay props evaluating?
- React scroll nav using useRef in seperate routes
- Unable to manipulate the object to a specific format in Javascript
- Can't get Popover to display in correct position in Dialog
- React hooks doesn't re render component when props changes
- Passing data without props on a functionnal component?
- ReactJS: e.preventDefault() is not a function
- Retrieving images from json server and display with relevant question
- How can I match if the current route matches a pattern in React Router Dom v6?
- React: how to pass props from child to parent to another child?
- Jest setSystemTime not working with global scope
- useSelector hook and rerenders
- React component with re usable avatar
- React & MUI: Navigation on Mobile View
- How do I check if a React component is expecting a prop?
- How can I set a state to 'null' on click in a MERN w/ Redux app?
- How to use useeffect hook in react?
- custom checkbox react only one to check
- React TDD - How do I get inner text?
- How to pass react useState hook from parent to Child components
- How To implement ReactFlagsSelect with React Hook Form Controller
- How to.close accordion when clicked for the second time?