Confirm dialog
ProOne dialog for "are you sure?": a question, what will happen, and two actions, locked while the action runs, with a failure kept inside it. Not an M3 component (@windmorph/react-pro).
import { ConfirmDialog, ConfirmDialogActions } from '@windmorph/react-pro';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Props
ConfirmDialog 25 props
The question, short, naming the thing ("Remove Alex from the team?"). It names the dialog.
The acting button's name: what happens ("Remove", "Delete post"), never "OK".
What will happen, in a sentence or two. It describes the dialog to assistive tech.
Anything else the decision needs, between the description and the actions: a password, a reason.
The action can't be undone: the acting button takes the
errorrole.The acting button can't be pressed yet, such as with a field still empty.
The action is running (controlled): the acting button is pending, Cancel is disabled and nothing closes the dialog. A promise returned by
onConfirmsets it too.What went wrong, in the app's words. It shows in an alert inside the dialog, is announced, and focus moves to the acting button so Enter tries again. Hidden while a retry runs.
Where focus starts:
cancel, the least destructive choice;confirm; orcontent, the first control inchildren, for a field that must be filled first.Ref to the root element.
Controlled open state, when not inside a
DialogTrigger.Initial open state when uncontrolled, when not inside a
DialogTrigger.Icon above the title (which is then centred). Decorative. Not shown in full screen.
Where a basic dialog sits: centred (the spec's default) or against one side of the window, keeping 24px from its edges on compact windows and 56px on wider ones. For any other position, align it with
classNames.positioner(for example"items-start justify-end"for the top end corner). It also sets the motion's direction: centred or at the top the dialog slides down and grows downward as it enters, at the bottom up, and at the start or end along the x axis (mirrored in right-to-left layouts).How a basic dialog enters and leaves.
revealis the M3 dialog motion: it slides 50px away from the edge it sits against while its container grows from that edge, and its headline and content, then its actions, fade in.scaleis the library's original pop, an extension beyond the M3 motion: the dialog fades in while it scales up from 90%, and fades out while it scales to 95%, from the centre (placement="center") or from the edge it sits against. Either way reduced motion keeps only the fades andinstantturns the motion off. A full-screen dialog keeps its own motion and ignores it.Skips the enter and exit motion: the dialog, its parts and the scrim appear and leave at once, and the dialog leaves the document as soon as it closes. Reduced motion already keeps only the fades.
Events
Called when the dialog opens or closes; never to close while the action runs.
Called on a press of the acting button, once. When it returns a promise the dialog is pending until that settles: it closes when the promise resolves and stays open when it rejects (give the words through
error). When it returns nothing, a dialog withopenstays open for the app to close, and one without closes at once.Called when the person backs out: the Cancel button, Escape or the back gesture.
Called when the dialog has finished opening: once its enter motion (the slide, the container's growth and every part's fade) has ended, or right after it opens with
instant. Not called when it closes before then.Called when the dialog has finished closing: once its exit motion has ended and it has left the document, or right after it closes with
instant.
Text
The words the dialog shows and announces, from the app's translations. English by default. A
LabelsProvidersets them for the whole app.
Goes on the outermost element, the full-window layer around the dialog (as on the core
Dialog), so a layout class never hides or clips it. Style the surface withclassNames.panel.Classes for each part, by slot: the core Dialog's and this dialog's own.
The question.
The area between the title and the actions: the description, a failure and the content.
What will happen, under the title.
The failure's alert.
The row of actions.
The action that backs out.
The action that acts.
The dialog's surface: its colour, corners, padding, size and shadow.
The icon above the title.
The dimmed layer behind the dialog.
The fixed, full-window flex box that places the dialog. It pads 24px on compact windows and 56px from the medium breakpoint, and
placementsets its alignment, so alignment classes here (items-*,justify-*) position the dialog anywhere within the spec's margin, and padding classes change that margin.
Goes on the outermost element, with
className.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
ConfirmDialogActions 14 props
The acting button's name: what happens ("Remove", "Save"), never "OK".
The action can't be undone: the acting button takes the
errorrole.The acting button can't be pressed yet, such as with a field still empty.
The action is running: the acting button is pending (it keeps focus and announces
labels.pending) and the action that backs out is disabled.submitmakes the acting button submit the form it sits in.Which action takes focus when it mounts, in a dialog that opens on it.
The acting button's element.
Ref to the root element.
Events
Called on a press of the acting button; not while
pending.Called on a press of the action that backs out.
Text
The words the row shows and announces, from the app's translations. English by default. A
LabelsProvidersets them for the whole app.
Classes for the row; they win over the defaults via
cn().Classes for each part, by slot.
Inline styles for the root element.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
Spec status
Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.
| Item | Status | Details |
|---|---|---|
An action that can't be undone (destructive) | Built | Configuration · Remove, Content |
Pending by promise, with a failure kept in the dialog (error) | Built | Configuration · Remove |
| In a trigger, with no state | Built | Configuration · Trigger |
Content the decision needs (initialFocus="content", confirmDisabled) | Built | Configuration · Content |
| Leaving with unsaved changes | Built | Use case · Unsaved |
The actions as a part, in a form dialog (ConfirmDialogActions) | Built | Use case · Form |
Pending by promise, with a failure kept in the dialog (
Builterror)Configuration · Remove
In a trigger, with no state
BuiltConfiguration · Trigger
Content the decision needs (
BuiltinitialFocus="content",confirmDisabled)Configuration · Content
Leaving with unsaved changes
BuiltUse case · Unsaved
The actions as a part, in a form dialog (
BuiltConfirmDialogActions)Use case · Form
Theming & tokens
Set the tokens below on the dialog or any ancestor. The dialog, its buttons and the failure's alert keep their own tokens, so a theme reaches them as anywhere else. className goes on the full-window layer around the dialog, as on the core Dialog; style each part with classNames: scrim, positioner, panel, icon, title, content, description, error, actions, cancel, confirm.
| Variable | Default | Paints |
|---|---|---|
--wm-confirm-dialog-gap | 16px | The space between the description, the failure and the content. |
--wm-confirm-dialog-description-color | var(--md-sys-color-on-surface-variant) | The description’s text. |
--wm-confirm-dialog-destructive-label-color | var(--md-sys-color-error) | The acting button’s label and state layer, with `destructive`. |