focusable
This library was generated with Nx.
Finds keyboard-focusable elements within a specified element’s subtree.
Available on npmjs.com.
Usage
In package.json
add a dependency to 'focusable':
{
"dependencies": {
"@pukanito/focusable": "1.0.0"
}
}
Use Focusable
:
import Focusable from '@pukanito/focusable'
const focus = new Focusable(element)
focus.focusables // Array of focusable elements
-
element
: The element, which subtree to search for focusable elements. Defaults todocument.documentElement
.
Properties
Focusable
has the following properties:
-
focusables
- Array of keyboard focusable elements -
firstFocusable
- First keyboard focusable element -
lastFocusable
- Last keyboard focusable element
Focusable
has the following methods:
-
isFirstFocusable(el)
- Returns true if the element is the first focusable. -
isLastFocusable(el)
- Returns true if the element is the last focusable.