Accessible Focus Trapping

JSON →
library 8.0.1 ·javascript
verified May 27, 2026

focus-trap is a vanilla JavaScript library designed to trap keyboard focus within a specified DOM node, essential for building accessible UI components like modals, dialogs, and sidebars. It ensures that users navigating with keyboard (Tab, Shift+Tab) or screen readers cannot escape the designated area, enhancing accessibility. The current stable version is 8.0.1, with releases occurring as needed for bug fixes (patch), new features (minor), and breaking changes (major). Key differentiators include its lightweight, framework-agnostic nature, robust handling of nested traps (pausing/unpausing), and its reliance on the well-maintained `tabbable` library for determining focusable elements. It handles initial focus, tabbing within the trap, blocking clicks outside, and restoring focus on deactivation. It explicitly supports modern desktop browsers and offers UMD builds for environments without bundlers.

total hits 16
actors 7 distinct systems
last hit 13h ago human
MetaBot
4
GPTBot
2
Script
1
Search engines
2
Humans
2

top countries 🇺🇸 United States · 🇨🇦 Canada · 🇫🇷 France · 🇬🇧 United Kingdom · 🇹🇷 Turkey