express.ui.update_slider
express.ui.update_slider(id,
*,
=None,
label=None,
valuemin=None,
max=None,
=None,
step=None,
time_format=None,
timezone=None,
session )
Change the value of a slider input on the client.
Parameters
id : str
-
An input id.
label : Optional[str] = None
-
An input label.
value : Optional[
SliderValueArg
| tuple[SliderValueArg
,SliderValueArg
]] = None-
A new value.
min : Optional[
SliderValueArg
] = None-
The minimum allowed value.
max : Optional[
SliderValueArg
] = None-
The maximum allowed value.
step : Optional[
SliderStepArg
] = None-
Specifies the interval between each selectable value on the slider. Either
None
(the default), which uses a heuristic to determine the step size or a single number. If the values are dates, step is in days; if the values are date-times, step is in seconds. time_format : Optional[str] = None
-
Only used if the slider values are date or datetime objects. A time format string, to be passed to the Javascript strftime library. See https://github.com/samsonjs/strftime for more details. For Dates, the default is “%F” (like “2015-07-01”), and for Datetimes, the default is “%F %T” (like “2015-07-01 15:32:10”).
timezone : Optional[str] = None
-
Only used if the values are datetime objects. A string specifying the time zone offset for the displayed times, in the format “+HHMM” or “-HHMM”. If
None
(the default), times will be displayed in the browser’s time zone. The value “+0000” will result in UTC time. session : Optional[
Session
] = None-
A Session instance. If not provided, it is inferred via get_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, 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
Examples
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.py
from shiny import reactive
from shiny.express import input, ui
ui.input_slider("receiver", "Receiver:", min=0, max=100, value=50, step=1, width="100%")
ui.p("Change the min and max values below to see the receiver slider above update.")
with ui.layout_column_wrap(width=1 / 2):
ui.input_slider("min", "Min:", min=0, max=50, value=0, step=1)
ui.input_slider("max", "Max:", min=50, max=100, value=100, step=1)
@reactive.effect
def _():
# You can update the value, min, max, and step.
ui.update_slider(
"receiver",
value=max(min(input.receiver(), input.max()), input.min()),
min=input.min(),
max=input.max(),
)