The Button
widget allows triggering events when the button is clicked. In addition to a value
parameter, which will toggle from False
to True
while the click event is being processed an additional clicks
parameter that can be watched to subscribe to click events.
Discover more on using widgets to add interactivity to your applications in the how-to guides on interactivity. Alternatively, learn how to set up callbacks and (JS-)links between parameters or how to use them as part of declarative UIs with Param.
Parameters:
For details on other options for customizing the component see the layout and styling how-to guides.
Core
clicks
(int): Number of clicks (can be listened to)value
(boolean): Toggles fromFalse
toTrue
while the event is being processed.
Display
button_style
(str): The button style, either 'solid' or 'outline'.button_type
(str): A button theme; should be one of'default'
(white),'primary'
(blue),'success'
(green),'info'
(yellow),'light'
(light), or'danger'
(red).description
(str | Bokeh Tooltip | pn.widgets.TooltipIcon): A description which is shown when the widget is hovered.icon
(str): An icon to render to the left of the button label. Either an SVG or an icon name which is loaded from tabler-icons.io.icon_size
(str): Size of the icon as a string, e.g. 12px or 1em.disabled
(boolean): Whether the widget is editable.name
(str): The title of the widget.
The clicks
parameter will report the number of times the button has been pressed:
You can bind
to the Button
to trigger actions when the Button
is clicked.
You can also bind
to the clicks
parameter
Alternatively you can use the on_click
method to trigger a function when the button is clicked:
Styles
The color of the button can be set by selecting one of the available button_type
values and the button_style
can be 'solid'
or 'outline'
:
Icons
The Button
name string may contain Unicode and Emoji characters, providing a convenient way to define common graphical buttons:
However you can also provide an explicit icon
, either as a named icon loaded from tabler-icons.io/:
or as an explicit SVG:
Controls
The Button
widget exposes a number of options which can be changed from both Python and Javascript. Try out the effect of these parameters interactively: