Slackblocks.Elements.Button (slackblocks v2.8.0)

View Source

An interactive button that sends a payload or opens a URL.

Slack reference: https://docs.slack.dev/reference/block-kit/block-elements/button-element

Fields

  • text — Sets the button label. Required.
  • action_id — Sets the identifier Slack returns in interaction payloads when a user acts on this element. It must be unique among the elements of its block. Optional; nil omits the field.
  • url — Sets a URL opened in the user's browser when the button is clicked. Slack still sends an interaction payload. Optional; nil omits the field.
  • value — Sets the application-defined value sent in interaction payloads. Optional; nil omits the field.
  • style — Sets the button's emphasis. Omit it for the default neutral style. Optional; nil omits the field.
  • confirm — Sets a confirmation dialog shown before the action is sent. Optional; nil omits the field.
  • accessibility_label — Sets the label read by screen readers in place of the visible text. Optional; nil omits the field.

Summary

Functions

Atomically replaces supplied fields; omitted fields retain their values.

Constructs and validates a value. Text conveniences apply to keyword input.

Constructs a value or raises Slackblocks.ValidationError.

Types

t()

@type t() :: %Slackblocks.Elements.Button{
  accessibility_label: binary() | nil,
  action_id: binary() | nil,
  confirm: Slackblocks.Objects.Confirmation.t() | nil,
  style: Slackblocks.Types.button_style() | nil,
  text: Slackblocks.Objects.PlainText.t(),
  url: binary() | nil,
  value: binary() | nil
}

Functions

change(value, options)

@spec change(
  t(),
  keyword()
) :: {:ok, t()} | {:error, Slackblocks.ValidationError.t()}

Atomically replaces supplied fields; omitted fields retain their values.

change!(value, options)

@spec change!(
  t(),
  keyword()
) :: t()

Replaces fields or raises Slackblocks.ValidationError.

new(options)

@spec new(keyword()) :: {:ok, t()} | {:error, Slackblocks.ValidationError.t()}

Constructs and validates a value. Text conveniences apply to keyword input.

new!(options)

@spec new!(keyword()) :: t()

Constructs a value or raises Slackblocks.ValidationError.