Skip to content
Block Kit for React
Esc
↑↓navigate↵open⌘Jpreview
On this page

Button element

A clickable button, Slack's most common interactive element.

button is a clickable control that dispatches a block_actions payload when clicked. It can also carry a url to open a link, or a confirm object to ask before it fires.

Your AppAPP
onActionInteract with the preview.

Fields

PropType
typestring

Always button.

Typestring
textPlainTextElement

The button's label. As in Block Kit Builder, a label over 40 characters shows its first 40 and "…", and the action still sends the full text. Maximum length is 75 characters.

TypePlainTextElement
action_id?string

Identifies this action in the interaction payload. Must be unique within the block. Maximum length is 255 characters.

Typestring
value?string

Sent back in the interaction payload when the button is clicked. Maximum length is 2000 characters.

Typestring
url?string

A URL to open in a new tab when the button is clicked. Slack still sends the interaction payload; your app is expected to acknowledge it. Maximum length is 3000 characters.

Typestring
style?"primary" | "danger"

primary renders green, danger renders red. Omit for the default gray style. Use primary on at most one button in a set, and danger sparingly.

Type"primary" | "danger"
accessibility_label?string

Read by screen readers instead of text. Maximum length is 75 characters.

Typestring
confirm?ConfirmationDialog

Shows a confirmation dialog before the click is dispatched. See Confirmation dialogs.

TypeConfirmationDialog

Like Slack, buttons come in two sizes: the compact 28px button, at least 56px wide, in messages, and on App Home a 36px button with 15px text that is at least 80px wide.

Examples

Default, primary and danger styles

Your AppAPP

A url button still fires a block_actions payload; the browser navigation is a side effect the component performs in addition to dispatching. Only an http, https, mailto or slack URL (or a relative one) opens; anything else, like javascript:, is still sent in the action but never followed (see URL safety).

Your AppAPP
This is a section block with a button.
onActionInteract with the preview.

As a section accessory

A button can sit to the right of a section’s text instead of inside an actions block.

Your AppAPP
This is a section block with a button.
onActionInteract with the preview.

With a confirmation dialog

Add confirm to make a destructive action ask first. See Confirmation dialogs for the full object shape.

Your AppAPP
onActionInteract with the preview.

Interactivity

Clicking a button (after any confirm dialog is accepted) calls onAction with a button action and, if url is set, opens it in a new tab:

{
  "type": "button",
  "action_id": "approve",
  "block_id": "approval",
  "action_ts": "1706000000.000100",
  "text": { "type": "plain_text", "text": "Approve", "emoji": true },
  "value": "approve_123",
  "style": "primary"
}

url and style are only included when the element itself sets them, and a button with a confirm dialog sends that confirm object back too, as Slack does. A button doesn’t write to state.values: Slack only tracks state for elements that hold a value across interactions (selects, inputs, date pickers, and so on).

Last updated on