Alert Dialog
Interrupt a destructive action with an explicit confirmation decision.
Usage
Destructive confirmation
Require explicit confirmation before running an action that cannot be undone.
Require explicit confirmation before running an action that cannot be undone.
<!-- Alert Dialog / Destructive -->
<script setup lang="ts">
import { AlertDialogRoot, AlertDialogTrigger, AlertDialogOverlay, AlertDialogContent, AlertDialogTitle, AlertDialogDescription, AlertDialogClose } from '@sectile/vue/alert-dialog'
</script>
<template>
<AlertDialogRoot>
<AlertDialogTrigger>Delete project</AlertDialogTrigger>
<AlertDialogOverlay class="dialog-overlay" />
<AlertDialogContent>
<AlertDialogTitle>Delete project?</AlertDialogTitle>
<AlertDialogDescription>
This permanently removes the project and its deployment history.
</AlertDialogDescription>
<div class="actions">
<AlertDialogClose>Cancel</AlertDialogClose>
<AlertDialogClose class="danger">Delete project</AlertDialogClose>
</div>
</AlertDialogContent>
</AlertDialogRoot>
</template>Unsaved changes
Confirm before discarding changes that have not been saved.
Confirm before discarding changes that have not been saved.
<!-- Alert Dialog / Unsaved -->
<script setup lang="ts">
import { AlertDialogRoot, AlertDialogTrigger, AlertDialogOverlay, AlertDialogContent, AlertDialogTitle, AlertDialogDescription, AlertDialogClose } from '@sectile/vue/alert-dialog'
</script>
<template>
<AlertDialogRoot>
<AlertDialogTrigger>Discard draft</AlertDialogTrigger>
<AlertDialogOverlay class="dialog-overlay" />
<AlertDialogContent>
<AlertDialogTitle>Discard unsaved changes?</AlertDialogTitle>
<AlertDialogDescription>
Your edits to Release 0.3 will be lost.
</AlertDialogDescription>
<div class="actions">
<AlertDialogClose>Keep editing</AlertDialogClose>
<AlertDialogClose class="warning">Discard changes</AlertDialogClose>
</div>
</AlertDialogContent>
</AlertDialogRoot>
</template>Controlled
Let the parent own the current value and apply accepted changes back to the component.
Let the parent own the current value and apply accepted changes back to the component.
<!-- Alert Dialog / Controlled -->
<script setup lang="ts">
import { AlertDialogRoot, AlertDialogTrigger, AlertDialogOverlay, AlertDialogContent, AlertDialogTitle, AlertDialogDescription, AlertDialogClose } from '@sectile/vue/alert-dialog'
import { ref } from 'vue'
const open = ref(false)
</script>
<template>
<AlertDialogRoot v-model:open="open">
<AlertDialogTrigger>Delete project</AlertDialogTrigger>
<AlertDialogOverlay class="dialog-overlay" />
<AlertDialogContent>
<AlertDialogTitle>Delete project?</AlertDialogTitle>
<AlertDialogDescription>This action cannot be undone.</AlertDialogDescription>
<AlertDialogClose>Cancel</AlertDialogClose>
</AlertDialogContent>
</AlertDialogRoot>
</template>Outside interaction
closeOnInteractOutside controls whether a pointer interaction outside the content closes it. Elements in interactOutsideExclusions stay interactive in a modal and do not count as outside. For conditional decisions, call preventDefault() from the interact-outside event.
<AlertDialogRoot
:interact-outside-exclusions="[ignoredElement]"
@interact-outside="(event) => {
if (event.isInside(temporarilyIgnoredElement)) event.preventDefault()
}"
/>API
Vue package: @sectile/vue/alert-dialog
AlertDialogRootAlertDialogTriggerAlertDialogPortalAlertDialogOverlayAlertDialogContentAlertDialogTitleAlertDialogDescriptionAlertDialogClose
Props
AlertDialogRootProps
alignAlignment of positioned content relative to its anchor.
arrowPaddingMinimum space kept between an arrow and the edge of positioned content.
autoFocusWhether focus moves into the component when it opens.
avoidCollisionsWhether positioned content may flip or shift to remain visible.
closeOnInteractOutsideWhether interaction outside the content closes it.
collisionBoundaryBoundary used to keep positioned content visible.
collisionPaddingSpace kept between positioned content and its collision boundary.
defaultOpenInitial uncontrolled open state.
disabledWhether interaction is unavailable.
hideWhenDetachedWhether positioned content hides when its anchor leaves the layout.
initialFocusElement or resolver that receives focus when the component opens.
interactOutsideExclusionsElements that stay interactive and do not count as outside interaction.
labelAccessible name announced for the control.
openWhether the associated popup or disclosure is open.
restoreFocusWhether focus returns to the trigger when open content closes.
sidePreferred side of the anchor for positioned content.
sideOffsetDistance between positioned content and its anchor.
strategyCSS positioning strategy used for anchored content.
trackingUpdate strategy used while anchored content is open.
trapFocusWhether keyboard focus stays inside open content.
unmountOnExitWhether presence-managed content is removed from the DOM after its exit motion completes.
AlertDialogPartProps
asElement or component rendered for this part.
asChildWhether to merge this part into its single child instead of rendering a wrapper.
AlertDialogPortalProps
deferWhether Teleport target resolution waits until the end of the current mount or update tick.
disabledWhether interaction is unavailable.
toTeleport target for portalled content.
Slots
AlertDialogRootSlotProps
disabledWhether interaction is unavailable.
openWhether the associated popup or disclosure is open.
Other types
AlertDialogOpenChangeHandler
type AlertDialogOpenChangeHandler = PopupFactoryOptions['onOpenChange']AlertDialogInteractOutsideHandler
type AlertDialogInteractOutsideHandler = NonNullable<PopupFactoryOptions['onInteractOutside']>Parts
Shared scope: [data-scope="alert-dialog"]. Combine it with a part selector to keep styles local to this component.
| Part | Selector | Role | Extra attributes |
|---|---|---|---|
trigger | [data-part="trigger"] | Opens, closes, or activates the associated content. | — |
overlay | [data-part="overlay"] | Covers surrounding content while a modal surface is open. | — |
content | [data-part="content"] | Contains the component content shown for the active state. | — |
title | [data-part="title"] | Labels the associated content. | — |
description | [data-part="description"] | Describes the associated content or decision. | — |
close | [data-part="close"] | Closes or dismisses the current surface. | — |
Keyboard interaction
| Key | Behavior |
|---|---|
| Enter / Space | Activate the trigger or focused action. |
| Tab / Shift+Tab | Move through available controls; modal content keeps focus inside. |
| Escape | Close the popup and restore focus when configured. |
Accessibility
The alert dialog names its title and description, keeps modal focus inside, and restores focus on close.
See the corresponding WAI-ARIA pattern for the host accessibility contract.
