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

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

1 participant