An interactive component that inserts a button. The button can be a trigger for anything from opening a simple link to starting a complex workflow.

button_element(
  id,
  text,
  value = NULL,
  url = NULL,
  style = NULL,
  confirm = NULL
)

Arguments

id

character, An identifier for this action.

text

character, text of the button

value

The value to send along with the interaction payload. Default: NULL

url

character, A URL to load in the user's browser when the button is clicked. Default: NULL

style

Decorates buttons with alternative visual color schemes, Default: NULL

confirm

block_confirm, defines an optional confirmation dialog after the button is clicked. Default: NULL

Value

block element class

Details

  • Works with block types: Section, Actions

  • 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.

See also

Examples

# A regular interactive button: button_element(text = 'Click Me', value = 'click_me_123', id = 'button')
#> { #> "type": "button", #> "text": { #> "type": "plain_text", #> "text": "Click Me" #> }, #> "action_id": "button", #> "value": "click_me_123" #> }
# A button with a primary style attribute: button_element(text = 'Click Me', value = 'click_me_123', id = 'button',style = 'primary')
#> { #> "type": "button", #> "text": { #> "type": "plain_text", #> "text": "Click Me" #> }, #> "action_id": "button", #> "value": "click_me_123", #> "style": "primary" #> }
# A link button: button_element(text = 'Link Button', url = 'https://api.slack.com/block-kit', id = 'button')
#> { #> "type": "button", #> "text": { #> "type": "plain_text", #> "text": "Link Button" #> }, #> "action_id": "button", #> "url": "https://api.slack.com/block-kit" #> }