-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Expand file tree
/
Copy pathPositionedPopper.js
More file actions
73 lines (68 loc) · 2.63 KB
/
PositionedPopper.js
File metadata and controls
73 lines (68 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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 sx={{ justifyContent: 'flex-end' }} size={6}>
<Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'end' }}>
<Button onClick={handleClick('right-start')}>right-start</Button>
<Button onClick={handleClick('right')}>right</Button>
<Button onClick={handleClick('right-end')}>right-end</Button>
</Box>
</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>
);
}