Files
react-test/docs/data/material/components/popper/PositionedPopper.js
how2ice 005cf56baf
Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
init project
2025-12-12 14:26:25 +09:00

76 lines
2.6 KiB
JavaScript

import * as React from 'react';
import Box from '@mui/material/Box';
import Popper from '@mui/material/Popper';
import Typography from '@mui/material/Typography';
import Grid from '@mui/material/Grid';
import Button from '@mui/material/Button';
import Fade from '@mui/material/Fade';
import Paper from '@mui/material/Paper';
export default function PositionedPopper() {
const [anchorEl, setAnchorEl] = React.useState(null);
const [open, setOpen] = React.useState(false);
const [placement, setPlacement] = React.useState();
const handleClick = (newPlacement) => (event) => {
setAnchorEl(event.currentTarget);
setOpen((prev) => placement !== newPlacement || !prev);
setPlacement(newPlacement);
};
return (
<Box sx={{ width: 500 }}>
<Popper
// Note: The following zIndex style is specifically for documentation purposes and may not be necessary in your application.
sx={{ zIndex: 1200 }}
open={open}
anchorEl={anchorEl}
placement={placement}
transition
>
{({ TransitionProps }) => (
<Fade {...TransitionProps} timeout={350}>
<Paper>
<Typography sx={{ p: 2 }}>The content of the Popper.</Typography>
</Paper>
</Fade>
)}
</Popper>
<Grid container sx={{ justifyContent: 'center' }}>
<Grid>
<Button onClick={handleClick('top-start')}>top-start</Button>
<Button onClick={handleClick('top')}>top</Button>
<Button onClick={handleClick('top-end')}>top-end</Button>
</Grid>
</Grid>
<Grid container sx={{ justifyContent: 'center' }}>
<Grid size={6}>
<Button onClick={handleClick('left-start')}>left-start</Button>
<br />
<Button onClick={handleClick('left')}>left</Button>
<br />
<Button onClick={handleClick('left-end')}>left-end</Button>
</Grid>
<Grid container direction="column" sx={{ alignItems: 'flex-end' }} size={6}>
<Grid>
<Button onClick={handleClick('right-start')}>right-start</Button>
</Grid>
<Grid>
<Button onClick={handleClick('right')}>right</Button>
</Grid>
<Grid>
<Button onClick={handleClick('right-end')}>right-end</Button>
</Grid>
</Grid>
</Grid>
<Grid container sx={{ justifyContent: 'center' }}>
<Grid>
<Button onClick={handleClick('bottom-start')}>bottom-start</Button>
<Button onClick={handleClick('bottom')}>bottom</Button>
<Button onClick={handleClick('bottom-end')}>bottom-end</Button>
</Grid>
</Grid>
</Box>
);
}