express.ui.update_toolbar_input_select

express.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 Session instance. If not provided, it is inferred via get_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 reactive
from shiny.express import input, render, ui

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."
)

with ui.card():
    with ui.card_header():
        with ui.toolbar(align="right"):
            ui.toolbar_input_select("select", label="Choose", choices=["A", "B", "C"])
            ui.toolbar_input_button("update_btn", label="Update Select")

    with ui.card_body():

        @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,
    )