Skip to content

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.

Unsaved changes

Confirm before discarding changes that have not been saved.

Confirm before discarding changes that have not been saved.

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.

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.

template
<AlertDialogRoot
  :interact-outside-exclusions="[ignoredElement]"
  @interact-outside="(event) => {
    if (event.isInside(temporarilyIgnoredElement)) event.preventDefault()
  }"
/>

API

Vue package: @sectile/vue/alert-dialog

Components
  • AlertDialogRoot
  • AlertDialogTrigger
  • AlertDialogPortal
  • AlertDialogOverlay
  • AlertDialogContent
  • AlertDialogTitle
  • AlertDialogDescription
  • AlertDialogClose

Props

AlertDialogRootProps

align

Alignment of positioned content relative to its anchor.

arrowPadding

Minimum space kept between an arrow and the edge of positioned content.

autoFocus

Whether focus moves into the component when it opens.

avoidCollisions

Whether positioned content may flip or shift to remain visible.

closeOnInteractOutside

Whether interaction outside the content closes it.

collisionBoundary

Boundary used to keep positioned content visible.

collisionPadding

Space kept between positioned content and its collision boundary.

defaultOpen

Initial uncontrolled open state.

disabled

Whether interaction is unavailable.

hideWhenDetached

Whether positioned content hides when its anchor leaves the layout.

initialFocus

Element or resolver that receives focus when the component opens.

interactOutsideExclusions

Elements that stay interactive and do not count as outside interaction.

label

Accessible name announced for the control.

open

Whether the associated popup or disclosure is open.

restoreFocus

Whether focus returns to the trigger when open content closes.

side

Preferred side of the anchor for positioned content.

sideOffset

Distance between positioned content and its anchor.

strategy

CSS positioning strategy used for anchored content.

tracking

Update strategy used while anchored content is open.

trapFocus

Whether keyboard focus stays inside open content.

unmountOnExit

Whether presence-managed content is removed from the DOM after its exit motion completes.

AlertDialogPartProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

AlertDialogPortalProps

defer

Whether Teleport target resolution waits until the end of the current mount or update tick.

disabled

Whether interaction is unavailable.

to

Teleport target for portalled content.

Slots

AlertDialogRootSlotProps

disabled

Whether interaction is unavailable.

open

Whether the associated popup or disclosure is open.

Other types

AlertDialogOpenChangeHandler

ts
type AlertDialogOpenChangeHandler = PopupFactoryOptions['onOpenChange']

AlertDialogInteractOutsideHandler

ts
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.

PartSelectorRoleExtra 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

KeyBehavior
Enter / SpaceActivate the trigger or focused action.
Tab / Shift+TabMove through available controls; modal content keeps focus inside.
EscapeClose 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.

Released under the MIT License.