An accessible and keyboard-friendly React menu library.
Live examples and docs
Features
- React menu components for easy and fast web development.
- Unlimited levels of submenu.
- Supports dropdown or context menu.
- Supports radio and checkbox menu items.
- Flexible menu positioning.
- Comprehensive keyboard interactions.
- Unstyled components and easy customisation.
- Works in major browsers without polyfills.
- Adheres to WAI-ARIA Authoring Practices.
Install
npm install @szhsin/react-menu
yarn add @szhsin/react-menu
Usage
import { Menu, MenuItem, MenuButton, SubMenu } from '@szhsin/react-menu';
import '@szhsin/react-menu/dist/core.css';
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
License
MIT Licensed.