express.ui.update_toolbar_input_button
express.ui.update_toolbar_input_button(
id,
*,
label=None,
show_label=None,
icon=None,
disabled=None,
session=None,
)Update a toolbar button input on the client.
Change the value or appearance of a toolbar button input from the server.
Parameters
id : str-
The input ID.
label : Optional[TagChild] = None-
The new label for the button.
show_label : Optional[bool] = None-
Whether to show the label text.
icon : Optional[TagChild] = None-
The new icon for the button.
disabled : Optional[bool] = None-
Whether the button should be disabled.
session : Optional[Session] = None-
A
Sessioninstance. If not provided, it is inferred viaget_current_session.
Details
This update function works similarly to update_action_button, but is specifically designed for toolbar_input_button. It allows you to update the button’s label, icon, and disabled state from the server.
Note that you cannot change tooltip or border parameters after the button has been created, as these affect the button’s structure and ARIA attributes. Please use update_tooltip to update tooltip text.
When a tooltip is created for the select input, it will have an ID of "{id}_tooltip" which can be used to update the tooltip text dynamically via update_tooltip.
See Also
Examples
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.py
from faicons import icon_svg
from shiny import reactive
from shiny.express import input, render, ui
ui.h2("Update Toolbar Input Button Examples")
ui.p("These examples demonstrate updating a toolbar button's label and icon on click.")
with ui.card():
with ui.card_header():
"Update Label"
with ui.toolbar(align="right"):
ui.toolbar_input_button("btn", label="Click me")
with ui.card_body():
@render.text
def count():
return f"Button clicked {input.btn()} times"
@reactive.effect
@reactive.event(input.btn)
def _():
if input.btn() == 1:
ui.update_toolbar_input_button("btn", label="Clicked!")
with ui.card():
with ui.card_header():
"Update Icon"
with ui.toolbar(align="right"):
ui.toolbar_input_button(
"btn_icon", label="Save", icon=icon_svg("floppy-disk")
)
with ui.card_body():
@render.text
def count_icon():
return f"Button clicked {input.btn_icon()} times"
@reactive.effect
@reactive.event(input.btn_icon)
def _():
if input.btn_icon() == 1:
ui.update_toolbar_input_button(
"btn_icon", icon=icon_svg("circle-check"), label="Saved"
)