ui.update_date

ui.update_date(id, *, label=None, value=None, min=None, max=None, session=None)

Change the value of a date input on the client.

Parameters

id : str

An input id.

label : Optional[TagChild] = None

An input label.

value : Optional[date | str] = None

The starting date. Either a date() object, or a string in yyyy-mm-dd format. If None (the default), will use the current date in the client’s time zone.

min : Optional[date | str] = None

The minimum allowed value.

max : Optional[date | str] = None

The maximum allowed value.

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, [](: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 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("inDate", "Input date"),
)


def server(input: Inputs, output: Outputs, session: Session):
    @reactive.effect
    def _():
        d = date(2013, 4, input.n())
        ui.update_date(
            "inDate",
            label="Date label " + str(input.n()),
            value=d,
            min=d - timedelta(days=3),
            max=d + timedelta(days=3),
        )


app = App(app_ui, server)