button¶
A control that can trigger a function when pressed.
Properties¶
Name | Type | Default | Description |
---|---|---|---|
(★) |
dynamic(str|Icon) | "" | The label displayed in the button. |
on_action |
Callback | The name of a function that is triggered when the button is pressed.
|
|
active |
dynamic(bool) | True | Indicates if this component is active. |
id |
str | The identifier that will be assigned to the rendered HTML component. |
|
properties |
dict[str, any] | Bound to a dictionary that contains additional properties for this element. |
|
class_name |
dynamic(str) | The list of CSS class names that will be associated with the generated HTML Element. |
|
hover_text |
dynamic(str) | The information that is displayed when the user hovers over this element. |
(★)label
is the default property for this visual element.
Styling¶
All the button controls are generated with the "taipy-button" CSS class. You can use this class name to select the buttons on your page and apply style.
Stylekit support¶
The Stylekit provides specific classes that you can use to style buttons:
-
secondary
error
warning
success
Buttons are normally displayed using the value of the color_primary Stylekit variable. These classes can be used to change the color used to draw the button, respectively, with the color_secondary, color_error, color_warning and color_success Stylekit variable values.The Markdown content:
<|Error|button|class_name=error|><|Secondary|button|class_name=secondary|>
Renders like this:
Using color classes -
plain
The button is filled with a plain color rather than just outlined.The Markdown content:
<|Button 1|button|><|Button 2|button|class_name=plain|>
Renders like this:
Using the plain
class -
fullwidth: The button is rendered on its own line and expands across the entire available width.
Usage¶
Simple button¶
The button label, which is the button control's default property, is simply displayed as the button text.
Page content
<|Button Label|button|>
<taipy:button>Button Label</taipy:button>


Specific action callback¶
Button can specify a callback function to be invoked when the button is pressed.
Page content
<|Button Label|button|on_action=button_action_function_name|>
<taipy:button on_action="button_action_function_name">Button Label</taipy:button>