Button element
Welcome to the new home of Slack developer docs!
We're still building and not all features are available quite yet. Enjoy this peek into the future!
Not ready for the future? Return to the past at api.slack.com.
Example:
Fields
Field | Type | Description | Required? |
---|---|---|---|
type | String | The type of element. In this case type is always button . | Required |
text | Object | A 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_id | String | An 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_id s in the containing block. Maximum length is 255 characters. | Optional |
url | String | A 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 |
value | String | The value to send along with the interaction payload. Maximum length is 2000 characters. | Optional |
style | String | Decorates 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 |
confirm | Object | A confirm object that defines an optional confirmation dialog after the button is clicked. | Optional |
accessibility_label | String | A 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 |
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://api.slack.com/block-kit"
}