Skip to main content

Button element

Example:

Three buttons showing default, primary, and danger color styles

Fields​

FieldTypeDescriptionRequired?
typeStringThe type of element. In this case type is always button.Required
textObjectA text object that defines the button's text. Can only be of type: plain_text. text may truncate with ~30 characters. Maximum length for the text in this field is 75 characters.Required
action_idStringAn identifier for this action. You can use this when you receive an interaction payload to identify the source of the action. Should be unique among all other action_ids in the containing block. Maximum length is 255 characters.Optional
urlStringA URL to load in the user's browser when the button is clicked. Maximum length is 3000 characters. If you're using url, you'll still receive an interaction payload and will need to send an acknowledgement response.Optional
valueStringThe value to send along with the interaction payload. Maximum length is 2000 characters.Optional
styleStringDecorates buttons with alternative visual color schemes. Use this option with restraint.primary gives buttons a green outline and text, ideal for affirmation or confirmation actions. primary should only be used for one button within a set.danger gives buttons a red outline and text, and should be used when the action is destructive. Use danger even more sparingly than primary.If you don't include this field, the default button style will be used.Optional
confirmObjectA confirm object that defines an optional confirmation dialog after the button is clicked.Optional
accessibility_labelStringA label for longer descriptive text about a button element. This label will be read out by screen readers instead of the button text object. Maximum length is 75 characters.Optional
agent_promptStringA prompt sent to Slackbot when the button is clicked, if Slackbot AI is available to the user. Any app can set this field to a prompt of up to 4000 characters. Your app also receives a standard interaction payload.Optional
agent_prompt_displayStringShort text shown instead of the full agent_prompt in the user's Slackbot message. The user can expand the message to read the full prompt. Requires agent_prompt and defaults to the button's text.Optional
visible_to_user_idsArrayAn array of user IDs for which the button appears. If not provided, the button is visible to all users.Optional

Examples​

A regular interactive button:

{
"type": "button",
"text": {
"type": "plain_text",
"text": "Click Me"
},
"value": "click_me_123",
"action_id": "button"
}

A button with a primary style attribute:

{
"type": "button",
"text": {
"type": "plain_text",
"text": "Save"
},
"style": "primary",
"value": "click_me_123",
"action_id": "button"
}

A link button:

{
"type": "button",
"text": {
"type": "plain_text",
"text": "Link Button"
},
"url": "https://docs.slack.dev/block-kit"
}

A button that sends a prompt to Slackbot:

{
"type": "button",
"text": {
"type": "plain_text",
"text": "Summarize with Slackbot"
},
"action_id": "summarize_incident",
"agent_prompt": "Summarize this incident and suggest next steps.",
"agent_prompt_display": "Summarize this incident"
}
Handling agent prompt clicks

Your app receives a standard block_actions payload whether or not Slackbot AI is available to the user. Include an action_id to identify the button, and acknowledge the payload within 3 seconds.

If Slackbot AI is unavailable, clicking the button only sends the interaction payload.

The button element must be used inside either the section or actions block, like this:

{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "This is a section block with a button."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Click Me"
},
"value": "click_me_123",
"action_id": "button"
}
},
{
"type": "actions",
"block_id": "actionblock789",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Primary Button"
},
"style": "primary",
"value": "click_me_456"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Link Button"
},
"url": "https://api.slack.com/block-kit"
}
]
}
]
}

View in Block Kit Builder (opens in new tab)