Skip to main content

Button

Allows users for a button that can be clicked to perform an action.

app.button
app.button(icon=None, icon_position='start', block=False, danger=False, disabled=False, ghost=False,
href=None, html_type='button', loading=False, shape='default', size='middle', target=None,
type='default', on_click=None, label=None)

Parameters

ParameterDescription
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.
ghost (bool)If True, the button will have a transparent background with inverted text and border colors.
href (Optional[str])The URL to navigate to when the button is clicked.
html_type (ButtonHtmlType)The HTML type attribute of the button, such as submit, reset, or button.
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!")
)
Shapelets Basic Input
Shapelets 2024