Skip to content

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

Notifications You must be signed in to change notification settings

kalcifer/vue-focus-trap

Repository files navigation

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published