Skip to content

Minimal, zero-dependency React hook to create accessible menus (aka. dropdowns).

License

Notifications You must be signed in to change notification settings

rkusa/react-menu-hook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Menu Hook

Minimal, zero-dependency React hook to create accessible menus (aka. dropdowns).

Demo | NPM

Example

Minimal example:

import { useMenu } from "react-menu-hook";

export default function Menu() {
  const { isOpen, buttonProps, menuProps, getItemProps } = useMenu("main");

  return (
    <div>
      <button {...buttonProps}>Menu</button>

      {isOpen && (
        <ul {...menuProps}>
          <li {...getItemProps(() => {})}>Action 1</li>
          <li {...getItemProps(() => {})}>Action 2</li>
        </ul>
      )}
    </div>
  );
}

More advanced examples:

License

MIT

About

Minimal, zero-dependency React hook to create accessible menus (aka. dropdowns).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages