A component for Vue that traps user focus within a DOM element.
Install via npm:
% npm install vue-focus-trap
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.
isActive
:boolean
initialFocus
:(() => Element)
function returning an Element