Skip to content

Conversation

@KoolADE85
Copy link
Contributor

@KoolADE85 KoolADE85 commented Nov 7, 2025

At long last, here is a PR to modernize the date pickers.

You can play with them here:
https://dcc-redesign.plotly.app/datepickers-single
https://dcc-redesign.plotly.app/datepickers-range

Some improvements:

  • Consistent with dcc.Dropdown's look and feel
  • Keyboard accessible with focus carefully managed
  • Support for mouse drag & wheel (and click of course)
  • DatePickerRange supports selecting backwards as well as forwards
  • A range of tests added for both new and existing features.

Closes #3391
Fixes https://github.com/plotly/dash-design-kit/issues/1504

@KoolADE85 KoolADE85 force-pushed the feature/dcc-refactor-datepicker branch 2 times, most recently from b2d62da to de88f2b Compare November 7, 2025 17:48
@KoolADE85 KoolADE85 force-pushed the feature/dcc-refactor-datepicker branch from de88f2b to 75fd1fe Compare November 7, 2025 19:11
@AnnMarieW
Copy link
Collaborator

Wow! First look at this is amazing 🤩

I love how you can easily skip months and years - that's been a pain point in the old date pickers for a long time.

This is an incredible amount of work given that the Radix components does not have date pickers and you had to build all of this from scratch.

I see you are still using moment.js for the date formatting. Since they are no longer recommending moment.js to be used in new project, would you consider using one of their recommended alternatives? It might make it easier to add support for locale at some point https://momentjs.com/docs/#/-project-status/

@KoolADE85
Copy link
Contributor Author

Thanks @AnnMarieW ! And wow, I did not realize moment was fading away like that! I will take a look at replacing moment - it shouldn't be too much effort there.

Wow! First look at this is amazing 🤩

I love how you can easily skip months and years - that's been a pain point in the old date pickers for a long time.

This is an incredible amount of work given that the Radix components does not have date pickers and you had to build all of this from scratch.

I see you are still using moment.js for the date formatting. Since they are no longer recommending moment.js to be used in new project, would you consider using one of their recommended alternatives? It might make it easier to add support for locale at some point https://momentjs.com/docs/#/-project-status/

Copy link
Contributor

@T4rk1n T4rk1n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@T4rk1n
Copy link
Contributor

T4rk1n commented Nov 14, 2025

I see you are still using moment.js for the date formatting. Since they are no longer recommending moment.js

I would also recommend we change to something else, I don't think we use that much moment.js. Luxon seems like a good alternative, I also had a good experience with date-fns before.

@KoolADE85
Copy link
Contributor Author

I see you are still using moment.js for the date formatting. Since they are no longer recommending moment.js

I would also recommend we change to something else, I don't think we use that much moment.js. Luxon seems like a good alternative, I also had a good experience with date-fns before.

Oh nice, date-fns looks super lightweight, I'll give it a try!
Just want to call out... we document moment-style formatting for props like display_format and month_format. I guess in the interest of backwards-compatibility, I will write something that maps moment-style formats to date-fns-style (😒)

@AnnMarieW
Copy link
Collaborator

Sorry to comment on this after you already moved to date-fns, but just wanted to check if it's possible to add locales from a dash app with date-fns?

For example with day.js you can add different locales with a script. I didn't see an option to do that with date-fns without bundling the locales in the component.

scripts = [
    "https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.10.8/dayjs.min.js",      # dayjs  
    "https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.10.8/locale/fr.min.js",  # french locale
]

app = Dash(external_scripts=scripts)

Also, the day.js has a syntax that is more like moment so you may not have to write scripts for those format props.

@KoolADE85
Copy link
Contributor Author

Sorry to comment on this after you already moved to date-fns, but just wanted to check if it's possible to add locales from a dash app with date-fns?

For example with day.js you can add different locales with a script. I didn't see an option to do that with date-fns without bundling the locales in the component.

scripts = [
    "https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.10.8/dayjs.min.js",      # dayjs  
    "https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.10.8/locale/fr.min.js",  # french locale
]

app = Dash(external_scripts=scripts)

Also, the day.js has a syntax that is more like moment so you may not have to write scripts for those format props.

Excellent call @AnnMarieW ! It does support adding locales like that (or from the assets folder). However, I neglected to add the code that would make use of it! This is now added, along with a test.

@ndrezn
I think this qualifies as a "API change" for the DatePicker, so just want to run it past you. With this approach, if users want a localized calendar, they will need to provide an external script that provides the translations (e.g. https://cdn.jsdelivr.net/npm/[email protected]/locale/fr/cdn.min.js for French) or to put the script in their assets folder.
I don't think it's a big deal, but want to run it past you since non-English apps will need to perform this additional step when upgrading to the new components.

@AnnMarieW
Copy link
Collaborator

Wow - that's so awesome that you included the locale now. I just wanted to make sure it was possible to add at some point since this has been a frequently requested feature.

I think it's OK to document how to add the extra script, since this is a new feature.

@KoolADE85
Copy link
Contributor Author

Wow - that's so awesome that you included the locale now. I just wanted to make sure it was possible to add at some point since this has been a frequently requested feature.

I think it's OK to document how to add the extra script, since this is a new feature.

oh that's great then! For some reason, I had thought that moment.js had translations bundled in and handled them automatically. But if this actually adds a new translation feature, then even better!

@KoolADE85 KoolADE85 force-pushed the feature/dcc-refactor-datepicker branch from 682d832 to ab88a95 Compare November 20, 2025 17:31
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.

4 participants