shiny.ui.update_date#

shiny.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[str]) – An input label.

  • value (Union[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 (Union[date, str, None]) – The minimum allowed value.

  • max (Union[date, str, None]) – The maximum allowed value.

  • session (Optional[Session]) – 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

input_date

Example

#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
from shiny import *
from datetime import date, timedelta

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)
Return type

None