I wanted to remove the ripple effect on the button and implement my custom effect in MUI Button. I have removed ripple using disableRipple. I have tried to apply shadow when the user clicks on an element, but somehow it's not working.
import * as React from "react";
import Button from "@mui/material/Button";
import { alpha } from "@mui/material/styles";
export default function DefaultProps() {
return (
<Button
variant="outlined"
// className='Mui-focusVisible'
disableRipple
sx={{
"&:hover": {
boxShadow: `0px 0px 0px 0px ${alpha("#000", 0.16)}`
},
"&.Mui-focusVisible": {
boxShadow: `0px 0px 0px 50px ${alpha("#000", 0.16)}`
},
"&.Mui-active": {
boxShadow: `0px 0px 0px 8px ${alpha("#000", 0.16)}`
}
}}
>
Change default props
</Button>
);
}
I have used Mui-focusVisible to apply shadow on click as mentioned here is doc
disableRipple bool false
If true, the ripple effect is disabled. ⚠️ Without a ripple there is no styling for :focus-visible by default. Be sure to highlight the element by applying separate styles with the .Mui-focusVisible class.
My main intention is to achieve a click effect same as Ant Design. Check the button here: https://ant.design/components/button/
Sandbox: https://codesandbox.io/s/defaultprops-material-demo-forked-rhggn?file=/demo.js
Can anyone help me out?