import * as React from
'react'
;
import { styled } from
'@mui/material/styles'
;
import Box from
'@mui/material/Box'
;
import ButtonBase from
'@mui/material/ButtonBase'
;
import Typography from
'@mui/material/Typography'
;
const images = [
{
url:
title:
'Image 1'
,
width:
'30%'
,
},
{
url:
title:
'Image 2'
,
width:
'30%'
,
},
{
url:
title:
'Image 3'
,
width:
'30%'
,
},
];
const ImageButton = styled(ButtonBase)(({ theme }) => ({
position:
'relative'
,
height: 200
}));
const ImageSrc = styled(
'span'
)({
position:
'absolute'
,
left: 0,
right: 0,
top: 0,
bottom: 0,
backgroundSize:
'cover'
,
backgroundPosition:
'center 40%'
,
});
const Image = styled(
'span'
)(({ theme }) => ({
position:
'absolute'
,
left: 0,
right: 0,
top: 0,
bottom: 0,
display:
'flex'
,
alignItems:
'center'
,
justifyContent:
'center'
,
color: theme.palette.common.white,
}));
const ImageBackdrop = styled(
'span'
)(({ theme }) => ({
position:
'absolute'
,
left: 0,
right: 0,
top: 0,
bottom: 0,
backgroundColor: theme.palette.common.black,
opacity: 0.4,
}));
const ImageMarked = styled(
'span'
)(({ theme }) => ({
height: 3,
width: 18,
backgroundColor: theme.palette.common.white,
position:
'absolute'
,
bottom: -2,
left:
'calc(50% - 9px)'
,
}));
export
default
function
BasicButtonGroup() {
return
(
<div>
<div
className=
"head"
style={{
width:
"fit-content"
,
margin:
"auto"
,
}}
>
<h1
style={{
color:
"green"
,
}}
>
GeeksforGeeks
</h1>
<strong>React MUI ButtonBase API</strong>
<br />
<br />
</div>
<div
style={{
margin:
"auto"
,
}}
>
<Box sx={{
display:
'flex'
, flexWrap:
'wrap'
,
minWidth: 300, width:
'100%'
, gap:
'5px'
}}>
{images.map((image) => (
<ImageButton
focusRipple
key={image.title}
style={{
width: image.width,
}}
onFocusVisible={() => {
console.log(`${image.title} focused!`);
}}
disabled={image.title ===
'Image 2'
}
>
<ImageSrc style={{
backgroundImage: `url(${image.url})`
}} />
<ImageBackdrop
className=
"MuiImageBackdrop-root"
/>
<Image>
<Typography
component=
"span"
variant=
"subtitle1"
color=
"inherit"
sx={{
position:
'relative'
,
p: 4,
pt: 2,
pb: (theme) =>
`calc(${theme.spacing(1)} + 6px)`,
}}
>
{image.title}
<ImageMarked className=
"MuiImageMarked-root"
/>
</Typography>
</Image>
</ImageButton>
))}
</Box>
</div>
</div>
);
}