Skip to content

Alert Dialog

Ask for confirmation before an action continues.

Demos

Width

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Installation

Complete the shared installation. Copy AlertDialog.vue and index.ts into app/components/ui/alert-dialog/.

API

Variants and defaults

PropValuesDefault
widthxs, sm, md, lg, xlmd

width sets the floating surface width, independently of control size. The surface stays inside the viewport.

Props

PropTypeDefaultDescription
titlestring—Convenience title prop. Slot #title takes priority.
ariaLabelstring—Fallback accessible name when no title is rendered.
descriptionstring—Convenience description prop. Slot #description takes priority.
teleportstring | false"body"Teleport target for the dialog.
transitionstring | false"akaza-alert-dialog"Named Vue transition to apply.
durationnumber150Transition duration in ms.
asstring"div"Root element tag.
uiAlertDialogUi—CSS class overrides.

Slots

SlotScoped propsDescription
trigger{ isOpen, open, close, toggle }Element that opens the dialog.
header{ close, titleId }Header region.
title—Dialog title. Defaults to the title prop.
description—Description text. Defaults to the description prop.
body{ close, descriptionId }Main content area.
footer{ close }Action buttons region.

Events

EventPayloadDescription
open-change[open: boolean, details]Fired when the open state changes.

Exposed methods

MethodSignatureDescription
open(reason?, event?) => voidOpens the dialog.
close(reason?, event?) => voidCloses the dialog.
toggle(reason?, event?) => voidToggles the dialog.
titleIdstringAuto-generated id for the title element.
descriptionIdstringAuto-generated id for the description element.

Keyboard

KeyBehavior
Tab / Shift + TabCycles through focusable controls inside open alert dialog.
EscapeDoes not close the alert dialog. The user must choose an action.

Opening moves focus inside. Closing restores focus to previous element. Backdrop activation does not dismiss it.