import React, { useState } from
"react"
;
import Box from
"@mui/material/Box"
;
import Button from
"@mui/material/Button"
;
import Typography from
"@mui/material/Typography"
;
import Backdrop from
'@mui/material/Backdrop'
;
import Modal from
"@mui/material/Modal"
;
import { Fade } from
"@mui/material"
;
const style = {
position:
"absolute"
,
top:
"50%"
,
left:
"50%"
,
transform:
"translate(-50%, -60%)"
,
width: 300,
bgcolor:
"blue"
,
color:
"white"
,
px: 12,
py: 8,
borderRadius: 3
};
function
App() {
const [open, setOpen] = useState(
false
);
return
(
<div>
<div style={{ textAlign:
"center"
,
color:
"green"
}}>
<h1>GeeksforGeeks</h1>
<h2>React MUI Modal Util</h2>
</div>
<div style={{ textAlign:
"center"
}}>
<Button onClick={() => setOpen(
true
)}>
Open</Button>
<Modal open={open} onClose={() => setOpen(
false
)}
closeAfterTransition
BackdropComponent={Backdrop}
BackdropProps={{
timeout: 1000,
}}>
<Fade
in
={open}>
<Box sx={style}>
<Typography variant=
"h3"
>
GeeksforGeeks
</Typography>
<Typography sx={{ mt: 2 }}>
This modal is using transition
animation
in
opening and
closing of modal.
</Typography>
</Box>
</Fade>
</Modal>
</div>
</div>
);
}
export
default
App;