1.0.2 • Published 9 months ago

accessible-dropdown-menu v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

Accessible Dropdown Menu

Introducing a hook to create an accessible dropdown easily in few steps. This hook handles all the accessibility logic when building a dropdown menu, dropdown button, etc., and leaves the design completely up to you.

  • Fully accessible with keyboard and mouse navigations.
  • Zero dependencies

Usage

Import the hook:

import useDropdown from accessible-dropdown-menu

Use the hook:

const { buttonProps, itemProps, isOpen, setIsOpen } = useDropdownMenu<HTMLDivElement>(numberOfItems, currSelectedValue);

For button that triggers the dropdown:

<button
  {...buttonProps}
>

For options in the list:

<li
  key={option}
  {...itemProps[index]}
  >
  {name}
</li>
1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago