Confirmation dialogs
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 clicking outside the dialog) closes it and
nothing is logged: no action fires, and no element state changes.
Fields
title?PlainTextElement
The dialog's heading. Maximum length is 100 characters.
PlainTextElementtextPlainTextElement | MrkdwnElement
The explanatory body text. Maximum length is 300 characters.
PlainTextElement | MrkdwnElementconfirm?PlainTextElement
Label for the button that confirms the action. Maximum length is 30 characters. Defaults to "Confirm".
PlainTextElementdeny?PlainTextElement
Label for the button that cancels the action. Maximum length is 30 characters. Defaults to "Cancel".
PlainTextElementstyle?"primary" | "danger"
Color of the confirm button. `danger` renders red; omit for the default green `primary`.
"primary" | "danger"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 by clicking 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.