focus-trap/focus-trap
Trap focus within a DOM node. observed · 2026-08-28
Health v2 · maintenance only
92/100
- Activity 99
- Release rhythm 77
- Longevity 100
How is this computed?
round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10) — computed 2026-09-03. Adoption (stars, forks) is never an input.
- gap_med: 33
- age_days: 4035
- days_rel: 73
- days_push: 7
- n_releases_24m: 16
Adoption not part of the score
1564 stars · 123 forks observed · 2026-08-28
What it is AI-extracted, prompt v1, taxonomy v1, 2026-08-30, confidence not recorded
A small vanilla JavaScript library that traps keyboard focus within a DOM node, cycling Tab/Shift+Tab among its focusable elements and blocking outside clicks. It is designed for building accessible modals and dialogs, with framework wrappers like focus-trap-react available.
Use cases
- trap focus inside an accessible modal dialog
- keep Tab key cycling within a dropdown menu or drawer
- return focus to the trigger element when a dialog closes
- block clicks outside an open popover
- build accessible keyboard navigation for custom widgets
When to choose
- you need WAI-ARIA-compliant focus containment for modals or menus in vanilla JS or any framework
- you want a small, modular library with pause/resume and nested trap support
- you need broad browser support and a UMD build
When to avoid
- you use React and prefer a ready-made wrapper (use focus-trap-react instead)
- you need full dialog styling, animations, or overlay behavior (this only manages focus)
- your project does not involve keyboard/focus accessibility concerns
Facets
library · maturity stable
ui-components accessibility web-development frontend accessibility browser focus-management keyboard-navigation modal-dialog vanilla-js a11y nodejs
3 sources
- readme: https://github.com/focus-trap/focus-trap · fetched 2026-08-28 · e6095d500066
- homepage: http://focus-trap.github.io/focus-trap/ · fetched 2026-08-29 · 219b2a68b482
- registry_npm: https://registry.npmjs.org/focus-trap · fetched 2026-08-29 · 487f2dc766a8
Member repositories
| Repository | Role | Health v2 |
|---|---|---|
| focus-trap/focus-trap | main | 92 |
For agents
markdown · JSON · MCP: product_card(name="focus-trap/focus-trap")
Data as of 2026-08-30T08:39:29.467469+00:00 · Report a problem