kalcifer / vue-focus-trap

A component for Vue that traps user focus within a DOM element.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vue-focus-trap

A component for Vue that traps user focus within a DOM element.

Installation

Install via npm:

% npm install vue-focus-trap

Usage

import FocusTrap from "vue-focus-trap";
<FocusTrap v-bind:is-active="true">
  <Dialog />
</FocusTrap>

When isActive becomes true, it activates the focus trap. By default it sets the focus to the first focusable element within the component. This can be overriden with the initialFocus prop.

Props

  • isActive: boolean
  • initialFocus: (() => Element) function returning an Element

About

A component for Vue that traps user focus within a DOM element.


Languages

Language:JavaScript 77.2%Language:Vue 22.8%