1.0.0 • Published 2 years ago
@pukanito/focustrap v1.0.0
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.