Alert Dialog
Ask the user to confirm or cancel an important action in a centered panel that only closes when they choose.
Installation
This also adds Glass and Icon, which the glass variant draws with.
Usage
- 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
cancelaction'spressedemits, 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 totrueto open the dialog andfalseto 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>:
- Pressing an action closes the dialog, after
pressedemits, as every iOS and Android alert button does. You don't setopentofalseyourself. variantgives an action its role:cancelbacks out,destructivedeletes or can't be undone (it reads in red), anddefaultis 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. preferredmarks the action to take when the user agrees, such as Save. iOS 26 fills it with the theme'sglass-tint, and earlier iOS sets it in bold. Use it at most once, and never on the cancel action.
What each platform draws:
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.
Panel width
class goes on the panel, which is w-4/5 wide by default.
API
UiAlertDialog
UiAlertDialogFooter
UiAlertDialogAction
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.
Related
- Dialogs and overlays: how overlays work and which one to use
- Dialog: a dialog the backdrop can close
- Action Sheet: offer several actions instead of two
- Glass: the material the glass variant is drawn with
<overlay>: the element the dialog draws in
