express.ui.update_radio_buttons
express.ui.update_radio_buttons(
id,
*,
label=None,
choices=None,
selected=None,
inline=False,
session=None,
)
Change the value of a radio input on the client.
Parameters
id : str
-
An input id.
label : Optional[TagChild] = None
-
An input label.
choices : Optional[
ChoicesArg
] = None-
Either a list of choices or a dictionary mapping choice values to labels. Note that if a dictionary is provided, the keys are used as the (input) values so that the dictionary values can hold HTML labels.
selected : Optional[str] = None
-
The values that should be initially selected, if any.
inline : bool = False
-
If ``True```, the result is displayed inline
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.express.ui.input_numeric`) and
[](:func:`~shiny.express.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.express.ui.update_checkbox_group`), and
[](:func:`~shiny.express.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 reactive
from shiny.express import input, ui
ui.markdown("The first radio button group controls the second")
ui.input_radio_buttons(
"inRadioButtons", "Input radio buttons", ["Item A", "Item B", "Item C"]
)
ui.input_radio_buttons(
"inRadioButtons2", "Input radio buttons 2", ["Item A", "Item B", "Item C"]
)
@reactive.effect
def _():
x = input.inRadioButtons()
# Can also set the label and select items
ui.update_radio_buttons(
"inRadioButtons2",
label="Radio buttons label " + x,
choices=[x],
selected=x,
)