npm.io
1.0.0 • Published 3 years ago

@pukanito/focusable

Licence
MIT
Version
1.0.0
Deps
1
Size
22 kB
Vulns
0
Weekly
0

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 to document.documentElement.

Properties

Focusable has the following properties:

  1. focusables - Array of keyboard focusable elements
  2. firstFocusable - First keyboard focusable element
  3. lastFocusable - Last keyboard focusable element

Focusable has the following methods:

  1. isFirstFocusable(el) - Returns true if the element is the first focusable.
  2. isLastFocusable(el) - Returns true if the element is the last focusable.

Keywords