Skip to content

Instantly share code, notes, and snippets.

@AnnMarieW
Last active July 3, 2022 17:32
Show Gist options
  • Save AnnMarieW/3dc5e94fa7ebc72d44e6c0f9359a5528 to your computer and use it in GitHub Desktop.
Save AnnMarieW/3dc5e94fa7ebc72d44e6c0f9359a5528 to your computer and use it in GitHub Desktop.
Dash Mantine Components DatePicker with Locale
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