ui.update_text_area
ui.update_text_area(id,
*,
=None,
label=None,
value=None,
placeholder=None,
session )
Change the value of a text input on the client.
Parameters
id : str
-
An input id.
label : Optional[TagChild] = None
-
An input label.
value : Optional[str] = None
-
A new value.
placeholder : Optional[str] = None
-
A hint as to what can be entered into the control.
session : Optional[Session] = None
-
A
Session
instance. If not provided, it is inferred viaget_current_session
.
Note
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, [](:func:`~shiny.ui.input_numeric`) and
[](:func:`~shiny.ui.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 [](:func:`~shiny.ui.update_radio_buttons`), [](:func:`~shiny.ui.update_checkbox_group`), and
[](:func:`~shiny.ui.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
Examples
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.py
from shiny import App, Inputs, Outputs, Session, reactive, ui
app_ui = ui.page_fluid(
ui.layout_column_wrap(
ui.input_radio_buttons(
"pet_type", "Pet type", ["Dog", "Cat", "Bird"], inline=True
),
ui.input_radio_buttons("pet_sex", "Pet sex", ["Male", "Female"], inline=True),
ui.input_text("name", "Pet name", "Charlie"),
ui.input_text("royal_name", "Royal Name", "King Charlie"),
width=1 / 2,
)
)
def server(input: Inputs, output: Outputs, session: Session):
@reactive.effect
@reactive.event(input.pet_type)
def _():
# Update the label of the pet name input
ui.update_text("name", label=f"{input.pet_type()}'s name")
@reactive.effect
def _():
# Update the value of the royal name input
royal_noun = "King" if input.pet_sex() == "Male" else "Queen"
ui.update_text("royal_name", value=f"{royal_noun} {input.name()}")
app = App(app_ui, server)