import * as React from 'react'; import Backdrop from '@mui/material/Backdrop'; import Box from '@mui/material/Box'; import Modal from '@mui/material/Modal'; import Button from '@mui/material/Button'; import Typography from '@mui/material/Typography'; import { useSpring, animated } from '@react-spring/web'; interface FadeProps { children: React.ReactElement; in?: boolean; onClick?: any; onEnter?: (node: HTMLElement, isAppearing: boolean) => void; onExited?: (node: HTMLElement, isAppearing: boolean) => void; ownerState?: any; } const Fade = React.forwardRef(function Fade(props, ref) { const { children, in: open, onClick, onEnter, onExited, ownerState, ...other } = props; const style = useSpring({ from: { opacity: 0 }, to: { opacity: open ? 1 : 0 }, onStart: () => { if (open && onEnter) { onEnter(null as any, true); } }, onRest: () => { if (!open && onExited) { onExited(null as any, true); } }, }); return ( {React.cloneElement(children, { onClick })} ); }); const style = { position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)', width: 400, bgcolor: 'background.paper', border: '2px solid #000', boxShadow: 24, p: 4, }; export default function SpringModal() { const [open, setOpen] = React.useState(false); const handleOpen = () => setOpen(true); const handleClose = () => setOpen(false); return (
Text in a modal Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
); }