class ButtonElement implements ElementContract

Properties

protected PlainTextOnlyTextObject $text

A text object that defines the button's text.

protected string|null $actionId

An identifier for this action.

protected string|null $url

A URL to load in the user's browser when the button is clicked.

protected string|null $value

The value to send along with the interaction payload.

protected string|null $style

Decorates buttons with alternative visual color schemes. Use this option with restraint.

protected ConfirmObject|null $confirm

A confirm object that defines an optional confirmation dialog after the button is clicked.

protected string|null $accessibilityLabel

A label for longer descriptive text about a button element.

Methods

__construct(string $text, Closure|null $callback = null)

Create a new button element instance.

url(string $url)

Set the URL for the button.

id(string $id)

Set the action ID for the button.

value(string $value)

Set the value for the button.

primary()

Set the style for the button to primary.

danger()

Set the style for the button to danger.

confirm(string $text, Closure|null $callback = null)

Set the confirm object for the button.

accessibilityLabel(string $label)

Set the accessibility label for the button.

array
toArray()

Get the instance as an array.

Details

at line 84
__construct(string $text, Closure|null $callback = null)

Create a new button element instance.

Parameters

string $text
Closure|null $callback

at line 98
ButtonElement url(string $url)

Set the URL for the button.

Parameters

string $url

Return Value

ButtonElement

at line 112
ButtonElement id(string $id)

Set the action ID for the button.

Parameters

string $id

Return Value

ButtonElement

at line 126
ButtonElement value(string $value)

Set the value for the button.

Parameters

string $value

Return Value

ButtonElement

at line 140
ButtonElement primary()

Set the style for the button to primary.

Return Value

ButtonElement

at line 150
ButtonElement danger()

Set the style for the button to danger.

Return Value

ButtonElement

at line 160
ConfirmObject confirm(string $text, Closure|null $callback = null)

Set the confirm object for the button.

Parameters

string $text
Closure|null $callback

Return Value

ConfirmObject

at line 174
ButtonElement accessibilityLabel(string $label)

Set the accessibility label for the button.

Parameters

string $label

Return Value

ButtonElement

at line 188
array toArray()

Get the instance as an array.

Return Value

array