ui.update_date_range
ui.update_date_range(id,
*,
=None,
label=None,
start=None,
endmin=None,
max=None,
=None,
session )
Change the start and end values of a date range input on the client.
Parameters
id : str
-
An input id.
label : Optional[TagChild] = None
-
An input label.
start : Optional[date | str] = None
-
The starting date. Either a
date()
object, or a string in yyyy-mm-dd format. If an empty string is provided, the value will be cleared. end : Optional[date | str] = None
-
The ending date. Either a
date()
object, or a string in yyyy-mm-dd format. If an empty string is provided, the value will be cleared. min : Optional[date | str] = None
-
The minimum allowed value. If an empty string is passed there will be no minimum date.
max : Optional[date | str] = None
-
The maximum allowed value. If an empty string is passed there will be no maximum date.
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
#| '!! shinylive warning !!': |
#| shinylive does not work in self-contained HTML documents.
#| Please set `embed-resources: false` in your metadata.
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.py
from datetime import date, timedelta
from shiny import App, Inputs, Outputs, Session, reactive, ui
app_ui = ui.page_fluid(
ui.input_slider("n", "Day of month", min=1, max=30, value=10),
ui.input_date_range("inDateRange", "Input date"),
)
def server(input: Inputs, output: Outputs, session: Session):
@reactive.effect
def _():
d = date(2013, 4, input.n())
ui.update_date_range(
"inDateRange",
label="Date range label " + str(input.n()),
start=d - timedelta(days=1),
end=d + timedelta(days=1),
min=d - timedelta(days=5),
max=d + timedelta(days=5),
)
app = App(app_ui, server)