---
# A Magma pattern: the format and the commands are in docs/PATTERNS.md.
id: confirm-action
kind: pattern
title: Confirm an action
group: messages-and-states
layer: magma
status: decided
need: >-
  The person is about to do something that cannot be taken back, and must decide knowing what
  will happen.
principle: An action that cannot be taken back asks first, naming the item and the consequence.
keywords: [confirm, are you sure, delete, remove, undo, cannot be undone, irreversible, permanently]
not-for:
  - need: where the outcome of the action is told
    use: message-placement
  - need: payments, signatures and consent
    use: consent-and-legal
assumptions:
  - The action starts from a control the person chose (a button, a menu item).
high-stakes: true
components: [mds-modal, mds-banner, mds-text, mds-button, mds-toast-region, mds-toast]
related: [message-placement, error-recovery, notification-center, labels-and-values]
validated-on: []

variables:
  reversible: { values: ["yes", "no"], means: "can the person undo it afterwards" }
  reaches-others: { values: ["no", "yes"], means: "does it send something to other people or systems, which cannot be called back" }
  items: { values: [one, many], means: "how many items the action acts on" }
  frequency: { values: [occasional, frequent], means: "how often the same person does it in a working day" }
  stakes: { values: [normal, legal], means: "legal: money, a signature or consent, which have rules of their own" }
  preview: { values: [seen, unseen], means: "does the person see what goes and to whom when acting" }

cases:
  - id: act-then-undo
    reversible: "yes"
    reaches-others: "no"
    stakes: normal
    where: "act at once, then a toast with Undo, the default light toast, which stays until closed"
    use:
      - { role: "the place of the toasts of the application, once in its shell", use: mds-toast-region }
      - { role: "the toast that names what went; it stays until closed, its action with it", use: "mds-toast duration=0 dismissible" }
      - { role: "Undo, named by the verb that puts the item back", use: "mds-button slot=action size=sm variant=dark tone=outline" }
  - id: ask-first
    reversible: "no"
    reaches-others: "no"
    items: one
    frequency: occasional
    stakes: normal
    where: "a dialog before acting: the question names the item, the text says the consequence"
    use:
      - { role: "the dialog, named by its question", use: "mds-modal aria-label=<the question, naming the item>" }
      - { role: "the window of the dialog, its headline the question", use: "mds-banner slot=window variant=light tone=box dismissible headline=<the question, naming the item>" }
      - { role: "the consequence, in a sentence", use: mds-text }
      - { role: "Cancel, the safe choice, focused on opening", use: "mds-button slot=action variant=dark tone=outline autofocus" }
      - { role: "the action, last, named by its verb, in the colour of what destroys", use: "mds-button slot=action variant=error tone=strong" }
  - id: make-reversible
    reversible: "no"
    reaches-others: "no"
    items: one
    frequency: frequent
    stakes: normal
    where: "make it reversible: act at once, then a toast with Undo; the item is kept for a while to restore it"
    use:
      - { role: "the place of the toasts of the application, once in its shell", use: mds-toast-region }
      - { role: "the toast that names what went; it stays until closed, its action with it", use: "mds-toast duration=0 dismissible" }
      - { role: "Undo, named by the verb that brings the item back", use: "mds-button slot=action size=sm variant=dark tone=outline" }
    see: act-then-undo
  - id: ask-first-many
    reversible: "no"
    reaches-others: "no"
    items: many
    stakes: normal
    where: "a dialog before acting that says how many"
    use:
      - { role: "the dialog, named by its question", use: "mds-modal aria-label=<the question, saying how many>" }
      - { role: "the window of the dialog, its headline the question", use: "mds-banner slot=window variant=light tone=box dismissible headline=<the question, saying how many>" }
      - { role: "the consequence, in a sentence", use: mds-text }
      - { role: "Cancel, the safe choice, focused on opening", use: "mds-button slot=action variant=dark tone=outline autofocus" }
      - { role: "the action, last, named by its verb and how many, in the colour of what destroys", use: "mds-button slot=action variant=error tone=strong" }
  - id: send-as-shown
    reaches-others: "yes"
    preview: seen
    stakes: normal
    where: "no dialog: the Send button, with what and to whom in front of the person, is the confirmation; once sent, a success banner takes the place of the form, so nothing goes twice, and its action brings back an empty form"
    use:
      - { role: "the title of the page, which takes the focus when the form goes", use: "mds-text typography=page tag=h1 tabindex=-1" }
      - { role: "Send, the confirmation itself, waiting while the message goes", use: "mds-button type=submit await" }
      - { role: "the outcome, in place of the form", use: "mds-banner variant=success tone=strong headline=<what went>" }
      - { role: "what went and to whom", use: mds-text }
      - { role: "the way back to an empty form", use: "mds-button slot=action variant=success tone=strong" }
  - id: ask-before-sending
    reaches-others: "yes"
    preview: unseen
    stakes: normal
    where: "a dialog that shows what goes and to whom before sending"
    use:
      - { role: "the dialog, named by its question", use: "mds-modal aria-label=<the question, naming what goes and to whom>" }
      - { role: "the window of the dialog, its headline the question", use: "mds-banner slot=window variant=light tone=box dismissible headline=<the question, naming what goes and to whom>" }
      - { role: "the label of what goes, or of whom it goes to", use: "mds-text typography=label tag=dt" }
      - { role: "its value: the recipient, the text", use: "mds-text tag=dd" }
      - { role: "Cancel, the safe choice, focused on opening", use: "mds-button slot=action variant=dark tone=outline autofocus" }
      - { role: "Send, named by its verb, in the default primary strong: sending destroys nothing", use: "mds-button slot=action" }
gaps: []
not-applicable:
  - { stakes: legal, why: "payments, signatures and consent have legal rules of their own: the candidate consent-and-legal" }

always-true:
  - id: irreversible-asks
    rule: An action that cannot be taken back asks first.
    checked-by: review
  - id: names-item-and-consequence
    rule: The question names the item, the text says the consequence.
    checked-by: review
  - id: verb-not-ok
    rule: The confirm button repeats the verb ("Delete"), never "OK" or "Yes".
    checked-by: review
    note: a lint on the known words is possible
  - id: cancel-is-safe
    rule: Cancel and Esc never do the action.
    checked-by: review

open-choices:
  - { id: typed-confirmation, default: "none: the dialog that names the item and says how many is enough", may: "ask to type the name or the number for its gravest cases" }

situations:
  - { situation: A document is removed from a draft, case: act-then-undo }
  - { situation: An item is deleted for good, case: ask-first }
  - { situation: 12 items are deleted for good, case: ask-first-many }
  - { situation: "An item is archived, and can be restored", case: act-then-undo }
  - { situation: "An operator closes dozens of tickets a day, for good", case: make-reversible }
  - { situation: "A message is sent from its form, with the text and the recipient on screen", case: send-as-shown }
  - { situation: A reminder is sent to a person from the menu of a row, case: ask-before-sending }
  - { situation: A payment is confirmed, use: consent-and-legal }
---

# Confirm an action

**An action that cannot be taken back asks first, naming the item and the consequence.**

## When to use it

An action the person chose that cannot be taken back, or that sends something to other people:
delete for good, close for good, send. Not where its outcome is told (`message-placement`), not
payments, signatures and consent (`consent-and-legal`).

## What decides it

Six questions: whether the person can undo the action afterwards, whether it sends something
to other people or systems, whether it acts on one item or many, how often the same person does
it in a working day, whether money, a signature or consent is at stake, and whether the person
sees what goes and to whom when acting.

## Cases

<!-- Generated from the frontmatter: edit it there, then run nx run stencil:generate.pattern -- --sync. -->

| Variable | Values | Means |
| --- | --- | --- |
| `reversible` | `yes`, `no` | can the person undo it afterwards |
| `reaches-others` | `no`, `yes` | does it send something to other people or systems, which cannot be called back |
| `items` | `one`, `many` | how many items the action acts on |
| `frequency` | `occasional`, `frequent` | how often the same person does it in a working day |
| `stakes` | `normal`, `legal` | legal: money, a signature or consent, which have rules of their own |
| `preview` | `seen`, `unseen` | does the person see what goes and to whom when acting |

A case that leaves a variable out holds for any of its values.

| Case | When | Where |
| --- | --- | --- |
| `act-then-undo` | reversible: yes; reaches-others: no; stakes: normal | act at once, then a toast with Undo, the default light toast, which stays until closed |
| `ask-first` | reversible: no; reaches-others: no; items: one; frequency: occasional; stakes: normal | a dialog before acting: the question names the item, the text says the consequence |
| `make-reversible` | reversible: no; reaches-others: no; items: one; frequency: frequent; stakes: normal | make it reversible: act at once, then a toast with Undo; the item is kept for a while to restore it; see `act-then-undo` |
| `ask-first-many` | reversible: no; reaches-others: no; items: many; stakes: normal | a dialog before acting that says how many |
| `send-as-shown` | reaches-others: yes; stakes: normal; preview: seen | no dialog: the Send button, with what and to whom in front of the person, is the confirmation; once sent, a success banner takes the place of the form, so nothing goes twice, and its action brings back an empty form |
| `ask-before-sending` | reaches-others: yes; stakes: normal; preview: unseen | a dialog that shows what goes and to whom before sending |

Not applicable:

| When | Why |
| --- | --- |
| stakes: legal | payments, signatures and consent have legal rules of their own: the candidate consent-and-legal |

No gaps: every combination has a case or is not applicable.

The parts of each case, in the order of its preview: what each does in the case, and the component to write. A value in angle brackets is the text of the application, written as it says; the rest of the preview is its stage, the context of the case.

`act-then-undo`:

| Role | Use |
| --- | --- |
| the place of the toasts of the application, once in its shell | `mds-toast-region` |
| the toast that names what went; it stays until closed, its action with it | `mds-toast duration=0 dismissible` |
| Undo, named by the verb that puts the item back | `mds-button slot=action size=sm variant=dark tone=outline` |

`ask-first`:

| Role | Use |
| --- | --- |
| the dialog, named by its question | `mds-modal aria-label=<the question, naming the item>` |
| the window of the dialog, its headline the question | `mds-banner slot=window variant=light tone=box dismissible headline=<the question, naming the item>` |
| the consequence, in a sentence | `mds-text` |
| Cancel, the safe choice, focused on opening | `mds-button slot=action variant=dark tone=outline autofocus` |
| the action, last, named by its verb, in the colour of what destroys | `mds-button slot=action variant=error tone=strong` |

`make-reversible`:

| Role | Use |
| --- | --- |
| the place of the toasts of the application, once in its shell | `mds-toast-region` |
| the toast that names what went; it stays until closed, its action with it | `mds-toast duration=0 dismissible` |
| Undo, named by the verb that brings the item back | `mds-button slot=action size=sm variant=dark tone=outline` |

`ask-first-many`:

| Role | Use |
| --- | --- |
| the dialog, named by its question | `mds-modal aria-label=<the question, saying how many>` |
| the window of the dialog, its headline the question | `mds-banner slot=window variant=light tone=box dismissible headline=<the question, saying how many>` |
| the consequence, in a sentence | `mds-text` |
| Cancel, the safe choice, focused on opening | `mds-button slot=action variant=dark tone=outline autofocus` |
| the action, last, named by its verb and how many, in the colour of what destroys | `mds-button slot=action variant=error tone=strong` |

`send-as-shown`:

| Role | Use |
| --- | --- |
| the title of the page, which takes the focus when the form goes | `mds-text typography=page tag=h1 tabindex=-1` |
| Send, the confirmation itself, waiting while the message goes | `mds-button type=submit await` |
| the outcome, in place of the form | `mds-banner variant=success tone=strong headline=<what went>` |
| what went and to whom | `mds-text` |
| the way back to an empty form | `mds-button slot=action variant=success tone=strong` |

`ask-before-sending`:

| Role | Use |
| --- | --- |
| the dialog, named by its question | `mds-modal aria-label=<the question, naming what goes and to whom>` |
| the window of the dialog, its headline the question | `mds-banner slot=window variant=light tone=box dismissible headline=<the question, naming what goes and to whom>` |
| the label of what goes, or of whom it goes to | `mds-text typography=label tag=dt` |
| its value: the recipient, the text | `mds-text tag=dd` |
| Cancel, the safe choice, focused on opening | `mds-button slot=action variant=dark tone=outline autofocus` |
| Send, named by its verb, in the default primary strong: sending destroys nothing | `mds-button slot=action` |

## Parts

The dialog of `ask-first` and `ask-first-many`:

- the title is the question, with the name of the item ("Delete Mario Rossi?") or how many
  ("Delete 12 items?"); it is also the accessible name of the dialog;
- a sentence with the consequence ("They will no longer be able to sign in. Their changes
  stay, under their name.");
- an error banner, hidden, for when the action fails, `tone="strong"`, right above the row
  (`message-placement`, `action-failed-in-place`);
- at the end, Cancel (`variant="dark" tone="outline"`), then the action with its verb
  (`variant="error"` when it destroys).

The dialog of `ask-before-sending` is the same, with what goes and to whom in place of the
consequence (the recipient and the text, as labels and values), and the action with its verb in
the default `primary strong`: sending does not destroy.

The toast with Undo of `act-then-undo` and `make-reversible` is the default `light` toast, with
Undo as `mds-button size="sm" variant="dark" tone="outline"` in its `action` slot.

After `send-as-shown`, a success banner (`tone="strong"`) takes the place of the form: it names
what went and to whom, and its action ("Write another message") brings back the form, empty.

## Behaviour over time

- On the action: `await` on its button, which cannot be pressed again.
- A message sent from its form (`send-as-shown`): the form goes when the message went, so the
  same message cannot be sent twice by pressing again; the banner that takes its place is read
  out, and the focus goes to the title of the page.
- It works: the dialog closes, a toast that names what went, the default `light` toast of a
  removal (`message-placement`, `removal-toast-neutral`); if the element that opened the dialog
  is gone, the focus goes to the title of the page.
- It fails: the banner in the dialog, "Nothing was changed"; the dialog stays open.
- Cancel or Esc: the dialog closes (to verify on `mds-modal`: the focus goes back to what
  opened it).
- On opening, the focus is on Cancel, the safe choice; Esc means Cancel, so the dialog is not
  `strict`.
- The toast with Undo stays until it is closed, as every toast with an action
  (`message-placement`, `toast-action-stays`): the time limit to undo is kept by the
  application, which keeps the item for a while, not by the toast.

## Always true

<!-- Generated from the frontmatter: edit it there, then run nx run stencil:generate.pattern -- --sync. -->

These hold in every product: a product layer cannot change them.

| Id | Rule | Checked by |
| --- | --- | --- |
| `irreversible-asks` | An action that cannot be taken back asks first. | review |
| `names-item-and-consequence` | The question names the item, the text says the consequence. | review |
| `verb-not-ok` | The confirm button repeats the verb ("Delete"), never "OK" or "Yes". | review; a lint on the known words is possible |
| `cancel-is-safe` | Cancel and Esc never do the action. | review |

## Open choices

<!-- Generated from the frontmatter: edit it there, then run nx run stencil:generate.pattern -- --sync. -->

The default decides these; a product layer may narrow them.

| Id | Default | A product may |
| --- | --- | --- |
| `typed-confirmation` | none: the dialog that names the item and says how many is enough | ask to type the name or the number for its gravest cases |

## Situations

<!-- Generated from the frontmatter: edit it there, then run nx run stencil:generate.pattern -- --sync. -->

Situations every application has, each with its case: they give the examples, the texts and the keywords. The situations of a product's own domain go in its layer.

| Situation | Case |
| --- | --- |
| A document is removed from a draft | `act-then-undo` |
| An item is deleted for good | `ask-first` |
| 12 items are deleted for good | `ask-first-many` |
| An item is archived, and can be restored | `act-then-undo` |
| An operator closes dozens of tickets a day, for good | `make-reversible` |
| A message is sent from its form, with the text and the recipient on screen | `send-as-shown` |
| A reminder is sent to a person from the menu of a row | `ask-before-sending` |
| A payment is confirmed | not here: `consent-and-legal` |

## Decisions

| Date | Decision | Why |
| --- | --- | --- |
| 2026-10-16 | Proposed: an irreversible action always asks, naming the item and the consequence | Open decision of the docs site, `agents/patterns.md`. |
| 2026-10-28 | Draft with variables; the frequent irreversible action and the action that reaches others left as gaps | The sources do not settle them. |
| 2026-10-28 | An irreversible action done many times a day is made reversible, with Undo (`make-reversible`) | Asking every time teaches to confirm without reading, where the confirmation matters most. |
| 2026-10-28 | An action that reaches others asks only when the person does not see what goes and to whom (`send-as-shown`, `ask-before-sending`) | With the content and the recipient in front of them, the Send button is already the confirmation. |
| 2026-10-28 | The toast with Undo stays until closed | The rule of every toast with an action, there for accessibility; the time limit is the application's. |
| 2026-10-28 | No typed confirmation in the default; a product may add it (`typed-confirmation`) | The dialog that names the item and says how many is enough for a default. |
| 2026-11-01 | The toast of a removal, with Undo or after a confirmation, is the default `light` toast, not `success` (`act-then-undo`, `make-reversible`) | A removal is a loss the person wanted, and green celebrates it; on the neutral toast no colour judges the removal or Undo (`removal-toast-neutral` of `message-placement`). https://github.com/magma-design-system/magma/issues/1189#issuecomment-6556983924 |
| 2026-11-03 | Cancel is `dark outline`, the error banner of the dialog `tone="strong"` right above the row; the action of the toast with Undo is `size="sm" variant="dark" tone="outline"` | The rules of the domain Actions (`secondary`, `failed`, `toast`), which are newer than this pattern. Applied in review round 2 of the previews: https://github.com/magma-design-system/magma/issues/1233 |
| 2026-11-03 | After `send-as-shown`, a success banner takes the place of the form, and its action brings back an empty form; no toast | With the text still on screen and a toast that goes, the person may send the same message again in a few seconds without knowing it went. Asked in review round 2 of the previews: https://github.com/magma-design-system/magma/issues/1233 |
| 2026-11-13 | Each case gives the parts of its solution with their role, in the order of its preview, the stage of the preview marked `data-stage` | The `use` of a case named one part in five of what its preview shows, and no role: the agents of the products composed the rest by hand. https://github.com/magma-design-system/magma/issues/1396 |
