@pukanito/focusable
v1.0.0
Published
Get focusable child elements of a DOM element
Downloads
4
Maintainers
Readme
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 elementsfirstFocusable
- First keyboard focusable elementlastFocusable
- 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.