1.0.0 • Published 5 months ago

@pukanito/focustrap v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

focustrap

This library was generated with Nx.

Keeps focus trapped inside a HTMLElement when navigating with the keyboard.

Available on npmjs.com.

Usage

In package.json add a dependency to 'focustrap' and 'focusable':

{
  "dependencies": {
    "@pukanito/focustrap": "1.0.0",
    "@pukanito/focusable": "1.0.0"
  }
}

Use FocusTrap:

import { FocusTrap } from '@pukanito/focustrap';
const container = document.querySelector('...')!;
const focusTrap = new FocusTrap(container);
/* Focus trapped inside the container */
focusTrap.uninstall()
/* Focus no longer trapped */
  • container: The element where to trap focus.

Properties

FocusTrap has the following properties: 1. focusable - access the underlying Focusable.

FocusTrap has the following methods: 1. uninstall() - uninstalls the focus trap.

1.0.0

5 months ago

0.0.4

6 months ago

0.0.3

6 months ago

0.0.2

6 months ago

0.0.1

6 months ago