Confirmation dialog object
Add an "are you sure?" step to any interactive element with the confirm composition object.
confirm isn’t an element you place in a block. It’s a composition object you attach to an
interactive element’s own confirm field. When Slack renders the element and the user interacts
with it, a modal dialog appears first; the underlying action only fires if the user picks confirm.
Click Delete: the dialog opens and the actions log below stays empty until you pick a button.
Choosing “Delete” logs the block_actions payload for the button, exactly as if it had been
clicked with no confirm at all. Choosing “Cancel” (or pressing Escape, the close button, or
clicking outside the dialog) closes it and nothing is logged: no action fires, and no element state
changes.
Fields
titlePlainTextElement
The dialog's heading. Maximum length is 100 characters. Without one the renderer shows no heading.
PlainTextElementtextPlainTextElement | MrkdwnElement
The explanatory body text. Maximum length is 300 characters.
PlainTextElement | MrkdwnElementconfirmPlainTextElement
Label for the button that confirms the action. Maximum length is 30 characters. Without one the renderer shows "Confirm".
PlainTextElementdenyPlainTextElement
Label for the button that cancels the action. Maximum length is 30 characters. Without one the renderer shows "Cancel".
PlainTextElementstyle?"primary" | "danger"
Color of the confirm button. danger renders red; omit for the default green primary.
"primary" | "danger"Slack requires title, text, confirm and deny, and rejects a dialog missing any of them. The
renderer still shows one, with the fallbacks above, so a payload that works here can fail in
Slack.
Examples
A danger-style confirm on a delete button
Pair style: "danger" on the button with style: "danger" on its confirm object so the
button’s own color and the dialog’s confirm button agree.
Confirm on a select
Any *_select (and its multi_ variant) accepts confirm. It fires each time the value changes,
before the new selection is committed.
Confirm on checkboxes
Checkboxes and radio buttons also accept confirm. For checkboxes it only appears when checking
a box. Unchecking one never asks for confirmation.
Interactivity
confirm gates the element’s own action rather than emitting one of its own. What actually
happens when the user chooses confirm or deny:
- Confirm: the dialog closes, and the element behaves exactly as it would with no
confirmat all.onActionfires with the element’s normal payload, and (for stateful elements like selects, checkboxes, radio buttons, and date/time pickers)state.valuesupdates to the new value. - Deny, or dismiss with Escape, the close button or a click outside the dialog: the dialog
closes and nothing else happens.
onActiondoesn’t fire,state.valuesdoesn’t change, and (for aurlbutton) no new tab opens. The element is left exactly as it was before the interaction.
There’s no separate action payload for the confirm/deny choice itself. Slack doesn’t report it, and neither does this library.
Keyboard and screen readers
The dialog draws as Slack’s does: 520px wide, with the title and a close button on top, and it fades in over 80ms (at once with reduced motion). When it opens, focus moves to the dialog itself, as in Slack, so the first Tab reaches the close button, and Tab stays inside the dialog until it closes. Closing it gives focus back to the element that opened it.
It’s an alertdialog with aria-modal, named by its title and described by its text, so a screen
reader reads the question out as it opens. Slack itself marks it role="dialog"; alertdialog is
the role WAI-ARIA gives a dialog that interrupts to ask for confirmation.