Skip to main content

Component <Menu /> and <MenuItem />

PropsTypeMeaningPossible values
positionstringChange menu position around the elemettop-left / top / top-right / right-top / right / right-bottom / bottom-left / bottom / bottom-right / left-top / left / left-bottom
isOpenbooleanSet menu statustrue / false



Positions

const MenuPos = ({ position }) => {
const [isMenu, setMenu] = useState(false)

return (
<>
<button type="button" onClick={event => setMenu(event.currentTarget)}>
Open {position.replace('-', ' ')}
</button>

<Menu isOpen={isMenu} position={position} handleClose={() => setMenu(false)}>
<MenuItem>Milk</MenuItem>
<MenuItem disabled>Chokolate</MenuItem>
<MenuItem>Vegetables</MenuItem>
</Menu>
</>
)
}