Actions

Focus Trap

Description

The Focus Trap action can be used to trap a users focus inside of an element, this can be useful to manage focus inside of a modal for example.

Usage

<script lang="ts">
    import { focus_trap, type FocusTrapParameters } from 'action-archive';

    const focusTrapParameters: FocusTrapParameters = {
        initialFocus: true,
        disabled: false
    };
</script>

<div use:focus_trap={focusTrapParameters} />

Example

API

NameTypeDefaultDescription
initialFocusbooleantrueIndicates wether the first focusable element should gain focus upon initialization.
disabledbooleanfalseDisables the action.