Skip to content

[DateInput] Date range #1020

@arraydude

Description

@arraydude

Problem

With the current DateInput element there is no possible way to select a date range.

Solution

Background: st.slider allows users to pass a 2-element iterable into the value argument, in which case it shows a range slider and returns a 2-element tuple as output.

Proposal: Just copy what we do with st.slider! That is, allow the user to pass a 2-element iterable into st.date_input's value argument. When the user does that, the UI component should become a date-range picker, and the Python command should return a 2-element tuple as output:

start_date, end_date = st.date_picker("Pick a date range", [initial_value_for_start_date, initial_value_for_end_date])

...and in order to support creating a date-range picker without passing initial values, we should also accept 0-element iterables as input:

start_date, end_date = st.date_picker("Pick a date range", [])

(In fact, as part of the same PR can we also make st.slider support the API above, where you can pass a 0-element iterable?)

UI

On the JS/React side, our date picker component uses BaseWeb's DatePicker . Luckily, it looks like that component supports date ranges, via the range attribute. See the BaseWeb docs for more info.

Additional context

Metadata

Metadata

Assignees

Labels

type:enhancementRequests for feature enhancements or new features

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions