# focus-trap/focus-trap

Trap focus within a DOM node.

Repository: https://github.com/focus-trap/focus-trap
Canonical: https://ross.abutalabs.com/products/focus-trap
Homepage: http://focus-trap.github.io/focus-trap/
Language: JavaScript
License: MIT
License Family: permissive
Topics: dependabot
Last push: 2026-08-26T13:44:49+00:00

## Health v2 (maintenance only)
Score: 92/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 99, release rhythm 77, longevity 100
- inputs: {"age_days": 4035, "days_push": 7, "days_rel": 73, "gap_med": 33, "n_releases_24m": 16}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1564, forks 123 (observed 2026-08-28T04:05:04.173141+00:00)

## What it is
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
- artifact type: library
- maturity: stable
- function: ui-components, accessibility
- domain: web-development, frontend, accessibility
- platform: browser
- tags: focus-management, keyboard-navigation, modal-dialog, vanilla-js, a11y, nodejs

## Member repositories
- focus-trap/focus-trap (main) score 92

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:05:04.173141+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T04:00:13.281304+00:00, confidence not recorded.
  - readme: https://github.com/focus-trap/focus-trap (fetched 2026-08-28T04:05:04.173141+00:00, sha e6095d500066)
  - homepage: http://focus-trap.github.io/focus-trap/ (fetched 2026-08-29T11:29:06.077446+00:00, sha 219b2a68b482)
  - registry_npm: https://registry.npmjs.org/focus-trap (fetched 2026-08-29T11:29:06.087054+00:00, sha 487f2dc766a8)
- Data as of 2026-08-30T08:39:29.467469+00:00.
