I am trying to implement a one-second transition from the default color scheme to the hover color for a Button element in Material UI. I am using the
transitions.create(props, options)
method as described in this article: https://medium.com/@octaviocoria/custom-css-transitions-with-react-material-ui-5d41cb2e7c5. The transition does work, but the hover color appears immediately when the mouse hovers over the button. How can I delay the color change until the transition is finished?
Here is the relevant code snippet:
function Mbutton({ classes }) {
return (
<Button variant="outlined" className={classes.cart} disableRipple>
Add to Cart
</Button>
);
}
const styles = theme => ({
cart: {
padding: "6px 16px",
borderRadius: 0,
border: "2px solid #000",
"&:hover": {
transition: theme.transitions.create(["backgroundColor", "color"], {
duration: 1000
}),
backgroundColor: "#000",
color: "#fff"
}
}
});
You can also view and test it on Code Sandbox: https://codesandbox.io/s/mbutton-fogco
Thank you.