
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
react-accessible-dropdown-menu-hook
Advanced tools
A simple Hook for creating fully accessible dropdown menus in React
This Hook handles all the accessibility logic when building a dropdown menu, dropdown button, etc., and leaves the design completely up to you. It also handles the logic for closing the menu when you click outside of it.
Install with Yarn or npm:
yarn add react-accessible-dropdown-menu-hook
npm install react-accessible-dropdown-menu-hook
Import the Hook:
import useDropdownMenu from 'react-accessible-dropdown-menu-hook';
Call the Hook, telling it how many items your menu will have:
const { buttonProps, itemProps, isOpen } = useDropdownMenu(numberOfItems);
Spread the buttonProps
onto a button:
<button {...buttonProps}>Example</button>
Create the menu with the role='menu'
property and spread itemProps[x]
onto each item:
<div className={isOpen ? 'visible' : ''} role='menu'>
<a {...itemProps[0]} href='https://example.com'>Regular link</a>
<a {...itemProps[1]} onClick={handleClick}>With click handler</a>
</div>
Done!
Read the docs at: https://sparksuite.github.io/react-accessible-dropdown-menu-hook/docs/
See it in action: https://sparksuite.github.io/react-accessible-dropdown-menu-hook/demo/
Our team carefully studied and adhered to strict accessibility guidelines when designing this Hook. To learn more, see: https://sparksuite.github.io/react-accessible-dropdown-menu-hook/docs/design/accessibility.
We love contributions! Contributing is easy; learn how.
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.