Last active
November 23, 2024 15:42
-
-
Save AnnMarieW/3dc5e94fa7ebc72d44e6c0f9359a5528 to your computer and use it in GitHub Desktop.
Dash Mantine Components DatePicker with Locale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dash import Dash | |
import dash_mantine_components as dmc | |
scripts = [ | |
"https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.10.8/dayjs.min.js", | |
"https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.10.8/locale/fr.min.js", | |
] | |
# Default is English. To change the locale be sure to include proper localization file from dayjs library. | |
# See more options here: | |
# https://cdnjs.com/libraries/dayjs | |
# List of locale abbreviations: | |
# https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes | |
app = Dash(__name__, external_scripts=scripts) | |
app.layout = dmc.Container( | |
[ | |
dmc.DatePicker( | |
id="fr-date-picker", | |
label="Entrer la date", | |
locale="fr", | |
style={"width": 200}, | |
), | |
dmc.DatePicker( | |
id="date-picker", | |
label="Select Date", | |
style={"width": 200}, | |
allowFreeInput=True, | |
fixOnBlur=True, | |
), | |
dmc.DateRangePicker( | |
id="date-picker-range", | |
label="entrez la plage de dates", | |
style={"width": 200}, | |
locale="fr", | |
), | |
] | |
) | |
if __name__ == "__main__": | |
app.run_server(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @benoitfrisque
This is an old example - probably for dmc 0.12
Starting in 0.14 you need to set the
locale
in theDatesProvider
component. You can find an example in the docs:https://www.dash-mantine-components.com/components/datesprovider