Patterns / ConfirmationModal

ConfirmationModal

The confirmation modal asks the reader to confirm one action before it happens. It states the consequence in a line and offers a way out beside the action itself, so something that cannot easily be undone is never a single unguarded click.

On this page

The other pages in this section show compositions your own markup makes. This one the package ships. ConfirmationModal is a module: components arranged in one fixed way and published as a single export, imported exactly the way Button is.

Inside it is a compact Modal, whatever you pass as children, and a footer holding two Buttons. Nothing you could not have assembled yourself — the point is that every confirmation in every product is now the same one, down to which side Cancel sits on.

Three cases, in order: the everyday decision, the destructive one, and the one worth knowing about — a destructive action that is not a deletion. That third keeps the red button and renames it through confirmLabel, and passes no icon, since the glyph is optional.

When to use

Reach for it where one click does something the reader would want back — a deletion, a revocation, a send that reaches everyone — and the dialog buys them the moment it takes to read what it will cost. Ask rarely, though. A confirmation that fires on every save is clicked through without being read, and the habit of clicking through is formed long before something is genuinely at stake.

When not to use

A confirmation is one question with two answers, so anything carrying a field to fill in, a third option or a second step is a Modal — which is what this is built out of — and the tell is whether Cancel and the action really are the only two ways out. Never open one over another: a decision that takes two dialogs is a flow, and a flow is one Modal with a back step. And where the action can be undone, let it happen and say how to get back, because a gate in front of something reversible asks the reader to be sure about a risk they were never taking.

tone

Tone is the whole of the difference between the two confirmations, and it moves the label and the button together — there is no arrangement of props that puts Confirm on a red button.

toneWhen to use
defaultConfirm, on a primary button. For a decision worth stopping to make that leaves nothing behind it: publish, send, sign out everywhere.
destructiveDelete, on a danger button. For an action that removes something the reader cannot get back.