React-Menu

React component for building accessible menu, dropdown, submenu, context me...

README

React-Menu


An accessible and keyboard-friendly React menu library.



Features


- React menu components for easy and fast web development.
- Unlimited levels of submenu.
- Supports dropdown, hover, and context menu.
- Supports radio and checkbox menu items.
- Flexible menu positioning.
- Comprehensive keyboard interactions.
- Unstyled components and easy customisation.
- Optimal level support (level 3) ofReact 18 concurrent rendering.
- Supports server-side rendering.

Install


with npm

  1. ```bash
  2. npm install @szhsin/react-menu
  3. ```

or with Yarn

  1. ```bash
  2. yarn add @szhsin/react-menu
  3. ```

Usage


  1. ```jsx
  2. import { Menu, MenuItem, MenuButton, SubMenu } from '@szhsin/react-menu';

  3. export default function App() {
  4.   return (
  5.     <Menu menuButton={<MenuButton>Open menu</MenuButton>}>
  6.       <MenuItem>New File</MenuItem>
  7.       <MenuItem>Save</MenuItem>
  8.       <SubMenu label="Edit">
  9.         <MenuItem>Cut</MenuItem>
  10.         <MenuItem>Copy</MenuItem>
  11.         <MenuItem>Paste</MenuItem>
  12.       </SubMenu>
  13.       <MenuItem>Print...</MenuItem>
  14.     </Menu>
  15.   );
  16. }
  17. ```

**[Edit on CodeSandbox](https://codesandbox.io/s/react-menu-starter-3ez3c)**

**[Visit more examples and docs](https://szhsin.github.io/react-menu/)**

**[FAQs](docs/FAQs.md)**

Still on older versions? Please checkout our migration guides.

License


MIT Licensed.