Skip to content

button class

A control that can trigger a function when pressed.

Methods

__init__()

__init__(
    label="",
    on_action=None,
    width=None,
    active=True,
    id=None,
    properties=None,
    class_name=None,
    hover_text=None,
) -> None

Create a new button element.

Parameters:

Name Type Description Default

label

Union[str,Icon]
dynamic

The label displayed in the button.

on_action

Union[str, Callable]

A function or the name of a function that is triggered when the button is pressed.
This function is invoked with the following parameters:

  • state (State): the state instance.
  • id (str): the identifier of the button it it has one.
  • payload (dict): a dictionary that contains the key "action" set to the name of the action that triggered this callback.
None

width

Union[str, int]

The width of the button element.

None

active

bool
dynamic

Indicates if this element is active.
If False, the element is disabled, and user interaction is not allowed.

True

id

str

The identifier assigned to the rendered HTML component.
This can be used in callbacks or to target the element for styling.

None

properties

dict[str, Any]

A dictionary of additional properties that can be set to the element.

None

class_name

str
dynamic

A space-separated list of CSS class names to be applied to the generated HTML element.
These classes are added to the default taipy-button class.

None

hover_text

str
dynamic

The text that is displayed when the user hovers over the element.

None