Alert Dialog
A modal dialog that interrupts the user with important content and expects a response.
Preview
Installation
npx sigma-ui@latest add alert-dialogUsage
<script setup lang="ts">
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from '@/components/ui/alert-dialog';
</script>
<template>
<AlertDialog>
<AlertDialogTrigger>Open</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
<AlertDialogDescription>
This action cannot be undone.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction>Continue</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</template>- Use
v-model:openon<AlertDialog>to control the open state. - Unlike a regular dialog, it does not close when you click outside. The user has to pick
<AlertDialogCancel>or<AlertDialogAction>.
Examples
Basic
API Reference
AlertDialog
Props
| Prop | Type | Default |
|---|---|---|
unmountOnHideWhen set to | boolean | true |
openThe controlled open state of the dialog. Can be binded as | boolean | - |
defaultOpenThe open state of the dialog when it is initially rendered. Use when you do not need to control its open state. | boolean | - |
Events
| Event | Payload |
|---|---|
update:openEvent handler called when the open state of the dialog changes. | [value: boolean] |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
AlertDialogTrigger
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
AlertDialogContent
Props
| Prop | Type | Default |
|---|---|---|
forceMountUsed to force mounting when more control is needed. Useful when controlling animation with Vue animation libraries. | boolean | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
disableOutsidePointerEventsWhen | boolean | - |
Events
| Event | Payload |
|---|---|
escapeKeyDownEvent handler called when the escape key is down. Can be prevented. | [event: KeyboardEvent] |
pointerDownOutsideEvent handler called when a | [event: PointerDownOutsideEvent] |
focusOutsideEvent handler called when the focus moves outside of the | [event: FocusOutsideEvent] |
interactOutsideEvent handler called when an interaction happens outside the | [event: PointerDownOutsideEvent | FocusOutsideEvent] |
openAutoFocusEvent handler called when auto-focusing on open. Can be prevented. | [event: Event] |
closeAutoFocusEvent handler called when auto-focusing on close. Can be prevented. | [event: Event] |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
AlertDialogHeader
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
AlertDialogTitle
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
AlertDialogDescription
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
AlertDialogFooter
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
AlertDialogAction
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
AlertDialogCancel
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
Accessibility
Adheres to the Alert and Message Dialogs WAI-ARIA design pattern. Reka UI traps focus inside the dialog and returns it to the trigger on close.
| Key | Description |
|---|---|
| Space | Opens or closes the dialog. |
| Enter | Opens or closes the dialog. |
| Tab | Moves focus to the next focusable element. |
| Shift + Tab | Moves focus to the previous focusable element. |
| Esc | Closes the dialog and moves focus to the trigger. |