For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /dolan/alert-dialog.md.

Alert Dialog

Ask the user to confirm or cancel an important action in a centered panel that only closes when they choose.

Installation

npx @blotch/dolan add alert-dialog
import {
  UiAlertDialog,
  UiAlertDialogHeader,
  UiAlertDialogTitle,
  UiAlertDialogDescription,
  UiAlertDialogFooter,
  UiAlertDialogAction,
} from '../components/ui/alert-dialog';
Tip

This also adds Glass and Icon, which the glass variant draws with.

Usage

import { Component, signal } from '@angular/core';
import {
  UiAlertDialog,
  UiAlertDialogHeader,
  UiAlertDialogTitle,
  UiAlertDialogDescription,
  UiAlertDialogFooter,
} from '../components/ui/alert-dialog';
import { UiButton } from '../components/ui/button';

@Component({
  selector: 'app-delete-account',
  imports: [
    UiAlertDialog,
    UiAlertDialogHeader,
    UiAlertDialogTitle,
    UiAlertDialogDescription,
    UiAlertDialogFooter,
    UiButton,
  ],
  template: `
    <ui-button variant="destructive" (pressed)="open.set(true)">
      Delete account
    </ui-button>

    <ui-alert-dialog [(open)]="open">
      <ui-alert-dialog-header>
        <ui-alert-dialog-title>Are you sure?</ui-alert-dialog-title>
        <ui-alert-dialog-description>
          This action can't be undone.
        </ui-alert-dialog-description>
      </ui-alert-dialog-header>
      <ui-alert-dialog-footer>
        <ui-button variant="outline" (pressed)="open.set(false)">
          Cancel
        </ui-button>
        <ui-button variant="destructive" (pressed)="confirm()">
          Delete
        </ui-button>
      </ui-alert-dialog-footer>
    </ui-alert-dialog>
  `,
})
export class DeleteAccount {
  protected readonly open = signal(false);

  protected confirm(): void {
    // Delete the account here.
    this.open.set(false);
  }
}
  • Unlike Dialog, tapping the backdrop does nothing. Your buttons close it, so always include one that cancels.
  • Android's back button cancels it, as it does Material's dialogs: the cancel action's pressed emits, then the dialog closes. Set [cancelable]="false" on an alert that must be answered, and back does nothing while it's open.
  • [(open)] two-way binds a signal. Set it to true to open the dialog and false to close it.
  • The backdrop fades in and the panel scales up. Closing plays the reverse.
  • The dialog draws in an <overlay>, so it covers the whole screen wherever it sits in your template.
  • When it opens, a screen reader moves into the panel and stays inside it until the dialog closes.
  • <ui-alert-dialog-title> and <ui-alert-dialog-description> render <text>, so put plain text in them. The footer lays out its buttons in a row, aligned right.

Glass

variant="glass" draws the platform's own alert: Liquid Glass on iOS 26. Give it its buttons with <ui-alert-dialog-action>:

<ui-alert-dialog variant="glass" [(open)]="open">
  <ui-alert-dialog-header>
    <ui-alert-dialog-title>Delete Photo?</ui-alert-dialog-title>
    <ui-alert-dialog-description>
      This photo will be deleted from all your devices.
    </ui-alert-dialog-description>
  </ui-alert-dialog-header>
  <ui-alert-dialog-footer>
    <ui-alert-dialog-action variant="cancel">Cancel</ui-alert-dialog-action>
    <ui-alert-dialog-action variant="destructive" (pressed)="delete()">
      Delete
    </ui-alert-dialog-action>
  </ui-alert-dialog-footer>
</ui-alert-dialog>
  • Pressing an action closes the dialog, after pressed emits, as every iOS and Android alert button does. You don't set open to false yourself.
  • variant gives an action its role: cancel backs out, destructive deletes or can't be undone (it reads in red), and default is anything else.
  • The cancel action goes where each platform puts it: on the leading side of a row, and at the bottom of a stack, wherever you write it.
  • Two actions sit side by side, and three stack. For labels too long to share a row, set orientation="vertical" on the footer.
  • preferred marks the action to take when the user agrees, such as Save. iOS 26 fills it with the theme's glass-tint, and earlier iOS sets it in bold. Use it at most once, and never on the cancel action.
<ui-alert-dialog-footer>
  <ui-alert-dialog-action variant="cancel">Cancel</ui-alert-dialog-action>
  <ui-alert-dialog-action preferred (pressed)="save()"
    >Save</ui-alert-dialog-action
  >
</ui-alert-dialog-footer>

What each platform draws:

PlatformThe alert
iOS 26 and laterA 320pt Liquid Glass panel with 40pt corners. Leading bold title and message, 48pt capsule buttons. The screen dims to 20%
iOS 15 to 25Apple's alert before Liquid Glass: 270pt on the frosted material, centered text, buttons between hairlines, the preferred bold
AndroidMaterial 3's basic dialog: 28dp corners on the theme's secondary surface, text buttons at the end, a 32% scrim
Android, with provideGlass({ android: 'glass' })The iOS 26 alert, on glass without the refraction
Web previewThe iOS 26 alert, on Liquid Glass drawn with WebGL

As on iOS, the glass shrinks into place from a little larger as it fades in, and only fades as it goes. Material's dialog grows in from a little smaller. None of them blur the screen behind: Lynx has no backdrop-filter, so Tailwind's backdrop-blur-* classes would do nothing there anyway.

The default variant, and <ui-button>s in its footer, stay as they were. An <ui-alert-dialog-action> in it draws as an outline button for cancel, and a filled one otherwise.

Run code after it closes

closed emits once the close animation has finished, about 270ms after open turns false. It's a good place to navigate once the dialog has gone. You can also navigate straight from a button, as from any tap handler.

<ui-alert-dialog [(open)]="open" (closed)="onClosed()">…</ui-alert-dialog>

Panel width

class goes on the panel, which is w-4/5 wide by default.

<ui-alert-dialog [(open)]="open" class="w-11/12">…</ui-alert-dialog>

API

UiAlertDialog

InputTypeDefaultDescription
openbooleanfalseWhether the dialog is shown. Supports [(open)].
variant'default' | 'glass''default'glass draws the platform's own alert. See Glass.
cancelablebooleantrueWhether Android's back button cancels the dialog, running the cancel action's pressed if it has one.
classstring''Extra Tailwind classes for the panel.
OutputTypeDescription
openChangebooleanPart of [(open)]. Emits false when an <ui-alert-dialog-action> or Android's back button closes it, and never by itself.
closedvoidEmits after the close animation finishes.

UiAlertDialogFooter

InputTypeDefaultDescription
orientation'auto' | 'horizontal' | 'vertical''auto'How the glass variant lays out its actions. auto puts two side by side and stacks three, as iOS.
classstring''Extra Tailwind classes.

UiAlertDialogAction

InputTypeDefaultDescription
variant'default' | 'cancel' | 'destructive''default'The action's role.
preferredbooleanfalseThe action to take when the user agrees. Filled on iOS 26, bold before it.
accessibilityLabelstring—What a screen reader reads instead of the label.
classstring''Extra Tailwind classes.
OutputTypeDescription
pressedvoidEmits when the action is chosen, before the dialog closes.

UiAlertDialogHeader, UiAlertDialogTitle and UiAlertDialogDescription accept class.

Theme colors

The glass variant reads glass-foreground and glass-muted-foreground (its text), and glass-tint and glass-tint-foreground (the preferred action on iOS 26). See Glass.

Accessibility

  • When the dialog opens, a screen reader moves into the panel and stays inside it until the dialog closes.
  • Each action is a button named by its label, or by accessibilityLabel.
  • Reduce Motion: nothing scales. The dimming and the panel only fade, in both variants.
  • Reduce Transparency and Increase Contrast apply to the glass panel as to all glass.