React component for building accessible menu, dropdown, submenu, context menu, and more.
An accessible and keyboard-friendly React menu library.
with npm
npm install @szhsin/react-menu
or with Yarn
yarn add @szhsin/react-menu
import { Menu, MenuItem, MenuButton, SubMenu } from '@szhsin/react-menu';
export default function App() {
return (
<Menu menuButton={<MenuButton>Open menu</MenuButton>}>
<MenuItem>New File</MenuItem>
<MenuItem>Save</MenuItem>
<SubMenu label="Edit">
<MenuItem>Cut</MenuItem>
<MenuItem>Copy</MenuItem>
<MenuItem>Paste</MenuItem>
</SubMenu>
<MenuItem>Print...</MenuItem>
</Menu>
);
}
Edit on CodeSandbox
Visit more examples and docs
FAQs
Still on an old version? Please checkout our migration guides.
MIT Licensed.