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
Name | Type | Default | Description |
---|---|---|---|
initialFocus | boolean | true | Indicates wether the first focusable element should gain focus upon initialization. |
disabled | boolean | false | Disables the action. |