A Web Component wrapper that makes it easier to manage focus trapping
npm install focus-trapperFocusTrapper.js into your project and register it as a customElement;``js
import FocusTrapper from './FocusTrapper.js';
// Define the
customElements.define('focus-trapper', FocusTrapper);
`
After you have define the custom element you should be able to use it in your HTML.
`html`
By default the focus-trapper custom element won't do anything. To make it trap focus you'll need to add the trapped attribute. Once the trapped attribute is set in your markup, or the trapped property is set programmatically on an instance of an focus-trapper element, you'll be able to tab into the focusable content inside, but focus will always be moved from the last focusable element to the first and vice versa.
`html``