shiny.ui.update_text(id, *, label=None, value=None, placeholder=None, session=None)#

Change the value of a text input on the client.

  • id (str) – An input id.

  • label (Optional[str]) – An input label.

  • value (Optional[str]) – A new value.

  • placeholder (Optional[str]) – A hint as to what can be entered into the control.

  • session (Optional[Session]) – A Session instance. If not provided, it is inferred via get_current_session().


The input updater functions send a message to the client, telling it to change the settings of an input object. The messages are collected and sent after all the observers (including outputs) have finished running.

The syntax of these functions is similar to the functions that created the inputs in the first place. For example, input_numeric() and update_numeric() take a similar set of arguments.

Any arguments with None values will be ignored; they will not result in any changes to the input object on the client.

For update_radio_buttons(), update_checkbox_group(), and update_select(), the set of choices can be cleared by using choices=[]. Similarly, for these inputs, the selected item can be cleared by using selected=[].

See also



#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
from shiny import *

app_ui = ui.page_fluid(
    ui.input_slider("controller", "Controller", min=0, max=20, value=10),
    ui.input_text("inText", "Input text"),
    ui.input_text("inText2", "Input text 2"),

def server(input: Inputs, output: Outputs, session: Session):
    def _():
        x = str(input.controller())
        # This will change the value of input$inText, based on x
        ui.update_text("inText", value="New text " + x)
        # Can also set the label, this time for input$inText2
        ui.update_text("inText2", label="New label " + x, value="New text" + x)

app = App(app_ui, server)
Return type