tabbable is a JavaScript utility library designed to accurately identify and return an array of all keyboard-tabbable DOM nodes within a specified container element. It systematically determines tabbability based on standard HTML semantics (e.g., `<button>`, `<input>`, `<a>` with `href`), explicit `tabindex` attributes, and various visibility and accessibility rules. The library is actively maintained, currently at version `6.4.0`, and receives regular minor and patch updates to enhance browser compatibility, support new web standards like the `inert` attribute, and address issues in virtual DOM environments like JSDOM. Its key differentiators include a zero-dependency footprint, small bundle size, high accuracy in diverse scenarios, and optimized performance. It supports a broad range of modern desktop browsers (Chrome, Edge, Firefox, Safari, Opera), but crucially, it dropped support for Internet Explorer browsers starting with v6.0.0. The library also provides granular control over how visibility checks are performed via the `displayCheck` option, accommodating various application needs.
npm install tabbableVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to find both tabbable and focusable elements within a given DOM node using the `tabbable` and `focusable` functions, and how to retrieve their `tabIndex`.
Migrate your application to modern browsers. If IE11 support is critical, you must use `tabbable` v5.x or earlier.
For full compatibility and consistent behavior, consider polyfilling the `inert` attribute or implementing custom focus management for browsers that do not natively support it. Always test in target environments.
Upgrade JSDOM to version 26 or newer to ensure accurate `inert` attribute handling. If upgrading is not feasible, be aware that manual checks for inertness or adjustments to `displayCheck` might be necessary.
Ensure the container element is attached to the document (e.g., `document.body.appendChild(container)`) when using `displayCheck='full'` or `displayCheck='non-zero-area'`. Alternatively, set `displayCheck='none'` explicitly if working with detached DOM nodes.
If supporting legacy browsers, install and include a `CSS.escape` polyfill (e.g., `npm install css.escape`).
Ensure your JSDOM setup is current (v26+). Verify that elements within the trapped container are not inadvertently hidden or marked `inert` in a way not supported by your browser/JSDOM version. Consider adding `tabindex="0"` to explicitly make an element tabbable if it should be.
Ensure that any DOM nodes passed to `tabbable` (or its internal functions) are attached to the document. This issue was largely fixed in `v6.1.0` to handle detached nodes more gracefully, but may still manifest in specific edge cases or older versions.
No dependency data recorded yet.