I'm currently exploring Material-UI and trying to customize a component. My goal is to add a 'Border Length Animation' effect when hovering over the button. Unfortunately, I have yet to successfully implement this animation as intended.
For reference, you can check out this example:
https://www.youtube.com/watch?v=5mabAgEoD6A
If you'd like to view the complete code, it's available on CodeSandbox:
https://codesandbox.io/p/sandbox/admiring-scooby-shcq42?file=%2Fsrc%2FDemo.js
const ImageButton = styled(ButtonBase)(({ theme }) => ({
position: "relative",
height: 200,
[theme.breakpoints.down("sm")]: {
width: "100% !important", // Overrides inline-style
height: 100,
},
"&:hover, &.Mui-focusVisible": {
zIndex: 1,
"& .MuiImageBackdrop-root": {
opacity: 0.15,
},
"& .MuiImageMarked-root": {
opacity: 0,
},
"& .MuiTypography-root": {
border: "4px solid currentColor",
},
},
}));
<Typography
component="span"
variant="subtitle1"
color="inherit"
sx={{
position: "relative",
p: 4,
pt: 2,
pb: (theme) => `calc(${theme.spacing(1)} + 6px)`,
}}
>
<ImageMarked className="MuiImageMarked-root" />
</Typography>