ui.update_toolbar_input_select
ui.update_toolbar_input_select(
id,
*,
label=None,
show_label=None,
choices=None,
selected=None,
icon=None,
session=None,
)Update a toolbar select input on the client.
Change the value or appearance of a toolbar select input from the server.
Parameters
id : str-
The input ID.
label : Optional[str] = None-
The new label for the select input.
show_label : Optional[bool] = None-
Whether to show the label text.
choices : Optional[SelectChoicesArg] = None-
The new choices for the select input.
selected : Optional[str] = None-
The new selected value.
icon : Optional[TagChild] = None-
The new icon for the select input.
session : Optional[Session] = None-
A
Sessioninstance. If not provided, it is inferred viaget_current_session.
Details
This update function works similarly to update_select_input, but is specifically designed for toolbar_input_select. It allows you to update the select’s label, icon, choices, selected value(s), and label visibility from the server.
Note that you cannot enable or disable the tooltip parameter after the select has been created, as this affects the select’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 App, Inputs, Outputs, Session, reactive, render, ui
app_ui = ui.page_fluid(
ui.h2("Update Toolbar Input Select Example"),
ui.p(
"This example demonstrates updating a toolbar select's label, choices, icon, and selected value when a button is clicked."
),
ui.card(
ui.card_header(
ui.toolbar(
ui.toolbar_input_select(
"select", label="Choose", choices=["A", "B", "C"]
),
ui.toolbar_input_button("update_btn", label="Update Select"),
align="right",
),
),
ui.card_body(
ui.output_text_verbatim("value"),
),
),
)
def server(input: Inputs, output: Outputs, session: Session) -> None:
@output
@render.text
def value():
return str(input.select())
@reactive.effect
@reactive.event(input.update_btn)
def _():
ui.update_toolbar_input_select(
"select",
label="Pick one",
choices=["New 1", "New 2", "New 3"],
selected="New 2",
icon=icon_svg("filter"),
show_label=True,
)
app = App(app_ui, server)