Alert Dialog
A modal window that alerts users with important information and awaits their acknowledgment or action.
Structure
API Reference
The root component used to set and manage the state of the alert dialog.
Property | Type | Description |
---|---|---|
open bindable prop | boolean | Whether or not the alert dialog is open. Default: false |
onOpenChange | function | A callback function called when the open state changes. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
The element which opens the alert dialog on press.
Property | Type | Description |
---|---|---|
child | Snippet | Use render delegation to render your own element. See render delegation for more information. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
ref | HTMLButtonElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
The content displayed within the alert dialog modal.
Property | Type | Description |
---|---|---|
onInteractOutside | function | Callback fired when an outside interaction event completes, which is either a Default: undefined |
onInteractOutsideStart | function | Callback fired when an outside interaction event starts, which is either a Default: undefined |
onFocusOutside | function | Callback fired when focus leaves the dismissable layer. You can call Default: undefined |
interactOutsideBehavior | enum | The behavior to use when an interaction occurs outside of the floating content. Default: close |
onEscapeKeydown | function | Callback fired when an escape keydown event occurs in the floating content. You can call Default: undefined |
escapeKeydownBehavior | enum | The behavior to use when an escape keydown event occurs in the floating content. Default: close |
onMountAutoFocus | function | Event handler called when auto-focusing the content as it is mounted. Can be prevented. Default: undefined |
onDestroyAutoFocus | function | Event handler called when auto-focusing the content as it is destroyed. Can be prevented. Default: undefined |
forceMount | boolean | Whether or not to forcefully mount the content. This is useful if you want to use Svelte transitions or another animnation library for the content. Default: false |
preventOverflowTextSelection | boolean | When Default: true |
preventScroll | boolean | When Default: true |
child | Snippet | Use render delegation to render your own element. See render delegation for more information. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
ref | HTMLDivElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
An overlay which covers the body when the alert dialog is open.
Property | Type | Description |
---|---|---|
forceMount | boolean | Whether or not to forcefully mount the content. This is useful if you want to use Svelte transitions or another animnation library for the content. Default: false |
child | Snippet | Use render delegation to render your own element. See render delegation for more information. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
ref | HTMLDivElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
A portal which renders the alert dialog into the body when it is open.
Property | Type | Description |
---|---|---|
to | union | Where to render the content when it is open. Defaults to the body. Can be disabled by passing Default: body |
disabled | boolean | Whether the portal is disabled or not. When disabled, the content will be rendered in its original DOM location. Default: false |
children | Snippet | The children content to render. Default: undefined |
A button used to close the alert dialog by taking an action.
Property | Type | Description |
---|---|---|
child | Snippet | Use render delegation to render your own element. See render delegation for more information. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
ref | HTMLButtonElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
A button used to close the alert dialog without taking an action.
Property | Type | Description |
---|---|---|
child | Snippet | Use render delegation to render your own element. See render delegation for more information. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
ref | HTMLButtonElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
An accessibile title for the alert dialog.
Property | Type | Description |
---|---|---|
level | union | The heading level of the title. This will be set as the Default: 3 |
child | Snippet | Use render delegation to render your own element. See render delegation for more information. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
ref | HTMLDivElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
An accessibile description for the alert dialog.
Property | Type | Description |
---|---|---|
child | Snippet | Use render delegation to render your own element. See render delegation for more information. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
ref | HTMLDivElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
Examples
Controlled
If you want to control or be aware of the open
state of the dialog from outside of the component, bind to the open
prop.