Components

Alert Dialog

Source
Headless confirmation dialog primitive that interrupts the user with a required action or cancel.

Overview

AlertDialog is Dialog with role="alertdialog" preset. The role announces alert-dialog semantics and makes the dialog undismissable by an outside tap, so the user must choose an explicit action or cancel. Use it for destructive or irreversible confirmations.

Every part except AlertDialogRoot is a name alias over the Dialog primitive of the same shape, so <Dialog role="alertdialog"> is equivalent.

This is a layer of @vyui/core, behavior only and no styles. Compose it when you need a custom-styled confirmation flow.

Anatomy

<AlertDialogRoot>
  <AlertDialogTrigger />
  <AlertDialogPortal>
    <AlertDialogOverlay />
    <AlertDialogContent>
      <AlertDialogTitle />
      <AlertDialogDescription />
      <AlertDialogCancel />
      <AlertDialogAction />
    </AlertDialogContent>
  </AlertDialogPortal>
</AlertDialogRoot>

Usage

<script setup lang="ts">
import {
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogOverlay,
  AlertDialogPortal,
  AlertDialogRoot,
  AlertDialogTitle,
  AlertDialogTrigger,
} from '@vyui/core'
</script>

<template>
  <AlertDialogRoot>
    <AlertDialogTrigger>
      <text>Delete project</text>
    </AlertDialogTrigger>

    <AlertDialogPortal>
      <AlertDialogOverlay />
      <AlertDialogContent>
        <AlertDialogTitle>
          <text>Delete this project?</text>
        </AlertDialogTitle>
        <AlertDialogDescription>
          <text>This action cannot be undone.</text>
        </AlertDialogDescription>
        <AlertDialogCancel>
          <text>Cancel</text>
        </AlertDialogCancel>
        <AlertDialogAction>
          <text>Delete</text>
        </AlertDialogAction>
      </AlertDialogContent>
    </AlertDialogPortal>
  </AlertDialogRoot>
</template>

Features and behavior

  • Modal by default: the overlay blocks interaction with everything behind it and is not tap-to-dismiss.
  • open / v-model:open controls visibility; defaultOpen seeds uncontrolled state.
  • AlertDialogAction emits click then closes; AlertDialogCancel closes without acting. Both alias DialogClose.

API

AlertDialogRoot

PropDefaultType
defaultOpenfalseboolean | undefined

The open state of the alert dialog when it is initially rendered. Use when you do not need to control its open state.

openundefinedboolean | undefined

The controlled open state of the alert dialog. Can be bound with `v-model`.

EventPayload
update:open[value: boolean]

AlertDialogContent

Aliases DialogContent.

PropDefaultType
asAsTag | Component | undefined

The element or component this component should render as. Can be overwritten by `asChild`.

asChildboolean | undefined

Render through the passed child element instead of the default one, merging their props and behavior while keeping the primitive's.

backdropClassstring | undefined

Class merged onto the full-screen backdrop wrapper (the `OverlayBackdrop` that centers the panel). Core ships no dim or animation of its own; the element carries the Presence lifecycle classes and `bindanimation*` hooks, so the styled layer's keyframes drive the lifecycle just like the panel's.

backdropStyleRecord<string, any> | undefined

Style applied to the full-screen backdrop wrapper. No defaults — pass `backgroundColor`, alignment, etc. here for the modal dim/centering.

debugLogboolean | undefined

Verbose lifecycle tracing — forwarded to both backdrop + panel Presence.

transitionboolean | undefined

Opt the backdrop / panel into the animating-state classes (`ui-entering` / `ui-leaving` / `ui-animating` alongside `ui-open` / `ui-closed`). Off for callers that don't style transitions.

EventPayload
interactOutside[event: DismissableLayerEvent]
pointerDownOutside[event: DismissableLayerEvent]

AlertDialogAction / AlertDialogCancel

Both alias DialogClose.

PropDefaultType
as"view"AsTag | Component | undefined

The element or component this component should render as. Can be overwritten by `asChild`.

asChildboolean | undefined

Render through the passed child element instead of the default one, merging their props and behavior while keeping the primitive's.

No emitted events.

Accessibility

  • Announced with native alert-dialog semantics; include both AlertDialogTitle and AlertDialogDescription.
  • The content confines assistive tech via accessibility-exclusive-focus while open.
  • The dialog cannot be dismissed implicitly; only AlertDialogAction or AlertDialogCancel close it.
  • Dialog is the general, dismissible dialog primitive.
  • Modal is the styled @vyui/kit dialog.