Skip to content

Feature #2717: dcc.DateRangeSlider and dcc.DateSlider#3802

Open
ines-om wants to merge 1 commit into
plotly:devfrom
ines-om:date-slider
Open

Feature #2717: dcc.DateRangeSlider and dcc.DateSlider#3802
ines-om wants to merge 1 commit into
plotly:devfrom
ines-om:date-slider

Conversation

@ines-om
Copy link
Copy Markdown
Contributor

@ines-om ines-om commented May 30, 2026

This PR fixes #2717.

We implement a dcc.DateRangeSlider and a dcc.DateSlider that wraps the existing sliders, making them date compatible.

The features developed include:

  • Disabling specific dates, date ranges or events (like weekends and specific weekdays), through disable_flags and disabled_dates props;
  • An optional disabled dates indicator, which visually signals to the user where disabled dates are in the slider, through the disabled_dates_indicator prop;
  • A new property that prevents selected ranges from spanning over disabled dates, through the no_disabled_in_between prop, which wasn't in the original plan but made sense to include.

We initially proposed the ability to disable holidays, but decided against it because it would have meant maintaining holiday data for different countries, which felt like too much added complexity for limited benefit (users can just pass in the dates they want to disable).

These components make use of the previous sliders’ props, like steps (now year, month and day based), marks, min, max, vertical, etc.

Contributor Checklist

  • I have broken down my PR scope into the following TODO tasks
    • Created fragments/DateRangeSlider.tsx wrapping `dcc.RangeSlider'
    • Created components/DateRangeSlider.tsx
    • Created DateSlider.tsx wrapping dcc.DateRangeSlider
    • Changed sliders.css to contain date slider logic and addition of disabled dates indicator
    • Expanded types.ts to include date sliders' props
    • Added helpers.ts functions for logic of disabling dates, stepping dates, dealing with disabled date ranges, enforcing the optional no disabled dates in between rule, etc.
    • Created utils/computeDateSliderMarkers.ts
    • Added tests to helpers.test.ts and computeDateSliderMarkers.test.ts
  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

optionals

  • I have added entry in the CHANGELOG.md
  • If this PR needs a follow-up in dash docs, community thread, I have mentioned the relevant URLS as follows
    • this GitHub #PR number updates the dash docs
    • here is the show and tell thread in Plotly Dash community

existing sliders to make them date-compatible)

Components wrap existing sliders to make them date-compatible,
converting date strings to timestamps.

Features include date-based stepping (years/months/days),
indicators/snapping for disabled dates, and optional DatePickerSingle
inputs.

This prevents users from having to use complex work arounds just to
include dates in sliders, like in the mentioned issue.

Closes plotly#2717
Co-authored-by: Francisco Cruz <francisco.oliveira.cruz@tecnico.ulisboa.pt>
@sonarqubecloud
Copy link
Copy Markdown

@AnnMarieW
Copy link
Copy Markdown
Collaborator

Hi @ines-om

Nice work on this PR. Date-based controls are tricky to implement, and date sliders would be a nice addition to Dash. I spent some time testing it and wanted to share some initial feedback. I'll add more comments as I continue trying different features.

  • allow_direct_input prop should be removed since there are no input fields

  • Types for dates (value, min, max etc) need to accept datetime objects. See datepickers for an example.

  • Need to add integration tests using dash testing. See the other slider tests for examples

  • if marks are defined, it only allows dates at the predefined marks. To be consistant with other slider components, that should only be the case when step=None

  • Rather than having delta_days, delta_months delta_years, it would be better to have step (number | null) and step_unit ("day" | "month" | "year")

  • Note - It's common to select end-of-month dates for financial reports. That doesn't work currently. Try setting dcc.DateSlider(min="2025-01-31, max="2025-12-31, delta_months=1)

  • The labels overflow the containers at the min and max points:

image
  • at the max point there are two labels that overlap:

image
  • default format for tooltip should be yyyy-mm-dd (same as the default for the marks)
  • date shown in tooltip is off by one compared to value as shown in the callback

image

That's all I've found so far. Overall, this is a solid start!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add date support for dcc.Slider/dcc.RangeSlider

2 participants