Accessible Dialog Focus Trap Primitives — Development skill for Claude Code
Four small React hooks/components for accessible modals: focus trap, Escape to close, focus return to trigger and live-region announcements.
How to install Accessible Dialog Focus Trap Primitives
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open hyderhusainarastu/accessible-dialog-focus-trap-primitives and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
What Accessible Dialog Focus Trap Primitives does
Four small React hooks/components for accessible modals: focus trap, Escape to close, focus return to trigger and live-region announcements. Follows the WAI-ARIA dialog pattern. TypeScript, with tests, a worked example and a scaffold script.
Alternatives in Development
- Scan Trap — 单独检查一只股票是不是杀猪盘 / 有没有被资金套路 6.6k ★
- Pi Reserved Keybindings — Extensions cannot override these shortcuts — they are silently skipped by registerShortcut() 526 ★
- Aria Hr — Use the @aria-hr agent to help the user with the following people/HR matter: $ARGUMENTS 523 ★
README
Accessible Dialog Focus-Trap Primitives
Four small, independently-testable React primitives that together make any modal, dialog, drawer, popover, or menu behave the way the [WAI-ARIA Dialog (Modal) Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/) requires: keyboard focus stays trapped inside while it's open, Escape closes it, focus returns to whatever opened it, and state changes that don't move focus still get announced to screen readers.
useFocusTrap— cycles Tab/Shift+Tab focus inside a container while it's active, wrapping at the edges instead of escaping to the page behind it.useEscapeToClose— closes a surface on Escape, only while it's active, without stealing an Escape press meant for something else.useFocusReturn— hands back a callback that restores focus to the control that opened the surface, once it closes.LiveAnnouncer— a visually-hiddenaria-liveregion for announcing state changes that have no visible focus target of their own.
Each primitive's trickiest logic is factored into a plain, DOM-free function (`resolveTabTarget`, `isEscapeDismissal`) so it's unit-testable with no jsdom, no Testing Library, and no browser at all — see `references/*.test.ts`.
Installation
Fastest path: copy the code into your project. Using it as an agent skill is optional.
1. Copy or scaffold the code (no agent needed)
node scripts/scaffold-dialog-primitives.mjs --out-dir ./src/components/dialog-primitives
Or copy `references/` and `examples/` by hand. Needs Node.js 18+ for the script, a React 18+ project (the code uses `useId`, `useCallback`, `useEffect`) and, if you keep the bundled tests, a Vitest-compatible runner (Jest's API is close, so they will likely run unmodified).
2. Install as an agent skill (optional)
Run `./install.sh` with no flags to see options and detected tools; nothing changes until you pick a target.
| Surface | How | Status |
|---|---|---|
| Claude Code |
Related Skills
Generate Aria Pattern
Prompt: Generate an accessible ARIA pattern
Toll Bridge Lens
Free Claude Code skill: score any business as a toll bridge (7 questions, bypass/government/value-trap flags)
Contrast Guardrails
Claude Code Skill: pre-flight WCAG-AA color-contrast guardrails that stop your agent from shipping invisible b
Academic Dashboard
A private, local dashboard for Purdue Brightspace on Windows: calendar, to-do list, exams, announcements and W
Stakeholder Comms
Draft stakeholder updates tailored to audience — executives, engineering, customers, or cross-functional partn
Startup Announcements
A Claude skill for early-stage founders (pre-seed through Series A) who have news to share. It asks a few ques
Related Agents
A11y Planner
Accessibility Design Planner — 9-phase protocol for designing accessible implementations before coding. Maps i
Solidjs UI Developer
Use for implementing SolidJS components, UI features, forms, lists, modals, custom reactive primitives (create
Omd UX Engineer
섹션 단위 인터랙션 / 모션 / IA / 마이크로인터랙션 / 모바일 / 지각 성능 감사 + 코드 레벨 개선안. NN/g 10 휴리스틱, Refactoring UI, Material/iOS HIG,