Skip to content

Get started

Install

Loock is published to the NPM registry

bash
npm install @chialab/loock
bash
yarn add @chialab/loock
bash
pnpm add @chialab/loock

or use a CDN

You can use DNA via CDN thanks to unpkg:

ts
import { focusTrapBehavior } from 'https://unpkg.com/@chialab/loock?module';

Usage

Loock provides a set of utilities and behaviors to manage focus and keyboard navigation:

In the example below, we create a focus trap for a dialog element.

ts
import { focusTrapBehavior } from '@chialab/loock';

const dialog = document.getElementById('.dialog');
const trap = focusTrapBehavior(dialog, {
    inert: true,
});

dialog.addEventListener('open', () => {
    trap.connect();
});

Released under the MIT License.