ButtonElement

init

Creates a ButtonElement instance.

Name
Type
Required
Default
Description

text

string

true

The text for the button. Maximum length of 75.

callback

function

false

null

A callback function to configure the ButtonElement.

Return: The ButtonElement instance.

url

Sets the link URL for the ButtonElement instance.

Name
Type
Required
Default
Description

linkUrl

string

true

The link URL for the button instance. Maximum length of 3000 characters.

Return: The ButtonElement instance.

id

Sets a custom identifier for the ButtonElement instance.

Name
Type
Required
Default
Description

id

string

true

The custom identifier for the ButtonElement instance. Maximum of 255 characters.

Return: The ButtonElement instance.

value

Sets the value for the ButtonElement instance.

Name
Type
Required
Default
Description

value

string

true

The value for the ButtonElement instance. Maximum of 2000 characters.

Return: The ButtonElement instance.

primary

Sets the style of the ButtonElement to primary.

Name
Type
Required
Default
Description

No arguments

Return: The ButtonElement instance.

danger

Sets the style of the ButtonElement to danger.

Name
Type
Required
Default
Description

No arguments

Return: The ButtonElement instance.

confirm

Sets the confirm object for the ButtonElement instance.

Name
Type
Required
Default
Description

text

string

true

The text of the confirm object.

callback

function

false

A callback function to configure the confirm object.

Return: The newly created ConfirmObject instance.

accessibilityLabel

Sets the accessibility label for the button.

Name
Type
Required
Default
Description

label

string

true

The accessibility label for the button. Maximum length of 75 characters.

Return: The ButtonElement instance.

getMemento

Converts the ButtonElement instance to a serializable format.

Name
Type
Required
Default
Description

No arguments

Return: (struct) A struct representing this ButtonElement instance.

{
    "type": "button",
    "text": {
        "type": "plain_text",
        "text": "Click me"
    },
    "action_id": "button_click-me",
    "style": "optional, primary or danger",
    "confirm": {
        "title": {
            "type": "plain_text",
            "text": "Are you sure?"
        },
        "text": {
            "type": "plain_text",
            "text": "This will do some thing."
        },
        "confirm": {
            "type": "plain_text",
            "text": "Yes"
        },
        "deny": {
            "type": "plain_text",
            "text": "No"
        }
    },
    "accessibility_label": "optional, Button to do some thing"
}

Last updated