@zimpa/focus-trap
v0.2.0
Published
Trap the (keyboard) focus of an element with in a container element.
Downloads
3
Readme
@zimpa/focus-trap
Trap the (keyboard) focus of an element with in a container element.
Install
Install the package by running npm install --save @zimpa/focus-trap
.
Usage
// first create the trap, this an element where the focus stays when the client uses the TAB key.
const el = document.querySelector('.modal');
const trap = focusTrap(el);
// whenever you want to enable the trap use:
trap.enable();
// when you want to disable the trap use:
trap.disable();