sparksuite/react-accessible-dropdown-menu-hook
소개
A simple Hook for creating fully accessible dropdown menus in React
웹 및 앱 개발측정된 스타 증가
- in 24h
- 0
- in 7 days
- 기록 수집 중
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalReact Accessible Dropdown Menu Hook
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.
- ♿️ Fully accessible
- 📦 Written entirely in TypeScript
- 🔬 Thoroughly tested
- ⚡️ Zero dependencies
- ✨ Tiny size
Quick start
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!
Documentation
Read the docs at: https://sparksuite.github.io/react-accessible-dropdown-menu-hook/docs/
Demo
See it in action: https://sparksuite.github.io/react-accessible-dropdown-menu-hook/demo/
Accessibility notes
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.
Contributing
We love contributions! Contributing is easy; learn how.
관련 프로젝트 살펴보기
불러오는 중…