-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
dcc redesign: DatePickerSingle and DatePickerRange
#3495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b2d62da to
de88f2b
Compare
de88f2b to
75fd1fe
Compare
AnnMarieW
commented
Nov 11, 2025
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
commented
Nov 12, 2025
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/
@T4rk1n
T4rk1n
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
components/dash-core-components/src/components/DatePickerRange.tsx
Outdated
Show resolved
Hide resolved
components/dash-core-components/src/fragments/DatePickerRange.tsx
Outdated
Show resolved
Hide resolved
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
commented
Nov 17, 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-fnsbefore.
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
commented
Nov 18, 2025
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
commented
Nov 19, 2025
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 withdate-fns?For example with
day.jsyou can add different locales with a script. I didn't see an option to do that withdate-fnswithout 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.jshas a syntax that is more likemomentso 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/date-fns@3.6.0/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
commented
Nov 19, 2025
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
commented
Nov 20, 2025
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!
682d832 to
ab88a95
Compare
Uh oh!
There was an error while loading. Please reload this page.
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:
dcc.Dropdown's look and feelCloses #3391 #3451 #3425
Fixes https://github.com/plotly/dash-design-kit/issues/1504