-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[DateInput] Date range #1020
Description
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
- This other FR is related, but not exactly the same
- And here's a related discussion