Button
Allows users for a button that can be clicked to perform an action.
Function signature
app.button(icon=None, icon_position='start', block=False, danger=False, disabled=False,
href=None, loading=False, shape='default', size='middle', target=None,
type='default', on_click=None, label=None)
Parameters
Parameter | Description |
---|---|
icon (Optional[IconType]) | The icon to be shown on the button. |
icon_position (ButtonIconPosition) | The position of the icon on the button, either start or end . |
block (bool) | If True , the button will take up the full width of its parent. |
danger (bool) | If True , the button will be styled to indicate a dangerous action. |
disabled (bool) | If True , the button will be disabled and unclickable. |
href (Optional[str]) | The URL to navigate to when the button is clicked. |
loading (Union[bool, Annotated[int, Gt(0)]]) | Controls the loading state of the button, either as a boolean or with a delay in milliseconds. |
shape (ButtonShapeType) | The shape of the button, either default , circle , or round . |
size (ButtonSizeType) | The size of the button, either large , middle , or small . |
target (Optional[Union[ButtonTargetType, str]]) | Indicates where to open the linked document when href is provided. |
type (ButtonType) | The type of the button, such as primary , dashed , link , text , or default . |
on_click (ButtonOnClick) | The callback function to be executed when the button is clicked. |
label (Union[str, VisualComponent, None]) | The text or visual component to be displayed on the button. |
Example
The example below shows how to create a button component.
from shapelets.apps import dataApp
# Initialize the data app
app = dataApp()
# Create a button with various properties
button_component = app.button(
label="Click Me",
type="primary",
size="middle",
shape="round",
icon="user",
loading=False,
on_click=lambda src: print("Button clicked!")
)