Dialogs
A dialog interrupts, so it is the last resort: for what cannot be undone, a short task, or a blocking decision.
Rules
A dialog interrupts, so it is the last resort, not the default container. It is right for three things only: confirming an action that cannot be undone, a short focused task the person must finish or cancel (creating a hub), and a decision the app cannot proceed without (a new version is ready). Settings, filters and anything adjusted while looking at the content open inline, in a popover or in a side panel with a live preview, never a modal.
- Undo before confirm. A destructive action that can be reversed (a soft delete) runs at once and offers Undo for 30 seconds. A confirm dialog is reserved for what cannot be taken back: a payment, a permanent deletion, a message sent to other people.
- Reversible means the person can reverse it. A soft delete with no restore they can reach (no Undo, no restore control, no trash) is permanent to them, however the row is stored, and one slip loses it. Such an action holds its request until its Undo closes (
useUndoableRemovein@yroun/ui: the item hides at once, nothing is sent while Undo is on screen, a tab closed inside the window sends nothing and the item is still there next time) or it asks first. - Say what happens. The title names the action ("Pay {price}?"); the body is one or two sentences on what will happen and what cannot be taken back ("The charge is made immediately and cannot be undone. A refund is a separate request."). The examples are patterns, not screens. No "Are you sure?" with nothing else.
- The confirm button carries the verb ("Pay {price}", "Send"), never "OK" or "Confirm". A destructive confirm is
btn-danger; cancel is a quiet button beside it. - Button order: from
smup the actions sit right-aligned with the primary last; on phones they stack full width with the primary on top, next to the thumb.
| Phones | From sm up | |
|---|---|---|
| Shape | Bottom sheet: full width, rounded top corners | Centered, max-w-md (wide content up to max-w-xl) |
| Height | At most 90% of the dynamic viewport (90dvh: the URL bar and keyboard count); the panel scrolls itself, so the title and close control stay reachable | Same |
| Layer | Dimmed backdrop z-overlay, panel z-modal | Same |
| Elevation | The modal elevation token | Same |
Behavior, every dialog, every platform:
- It is announced as a dialog and labelled by its title (
role="dialog",aria-modal,aria-labelledbyon the web). - Focus moves into the dialog when it opens and stays inside it while it is open.
- Escape closes it, as its close control does; so does a tap on the backdrop where it has one, except while a submit is in flight.
- Focus returns to the control that opened it when it closes.
- The page behind does not scroll.
- It always has a way out, in every state it can show, and the dialog's shape decides where: a centered dialog or sheet puts its close control at the trailing end of the title row; a full-screen prompt puts it at the top leading corner, where iOS and Material both dismiss a full-screen surface. The two platforms agree on that position, not on the control (iOS also uses a text Cancel there), so the control is our choice, made for predictability: a full-screen prompt's close is an × icon button, 44pt, whose accessible name is the surface's cancel label, on every platform. A centered dialog or sheet keeps its text actions. A state with nothing in flight still needs it, because a prompt the person cannot leave traps them.
Where a dialog appears and how it is dismissed are shared across every surface; tone and colour may be local. A surface carries its identity in its tone (the Play dialogs keep the near-black Play card, ModalView tone="play", utility dialog-play), never in a second position or a second way to close. Moving a dialog for one surface charges the person a lookup at the moment they were interrupted (UX Cognitive Load Mandate, Spatial Memory) and costs one-hand reach.
A backdrop tap never navigates. Where closing a dialog means leaving the page, the backdrop does nothing and Escape, the close control and the dialog's own exit link carry the way out: a tap above a sheet is the one gesture made by accident, and everywhere else it costs nothing (backdropDismisses={false}).
| Platform | Confirm | Task or sheet |
|---|---|---|
| Web | ConfirmModal from @yroun/ui | ModalView from @yroun/ui |
| iOS | .confirmationDialog or .alert with role: .destructive | .sheet with presentationDetents and a visible drag indicator |
| Android | Material 3 AlertDialog | ModalBottomSheet |
The browser's window.confirm is never used: it cannot be styled, translated or tested, and it blocks the page.