Py.Cafe

amward/

dmc-datepicker-disabled-dates-0

dmc.DatePicker example with Disabled Dates

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

from datetime import datetime, timedelta

import dash_mantine_components as dmc
from dash import Dash, _dash_renderer, html
_dash_renderer._set_react_version("18.2.0")

app = Dash(external_stylesheets=dmc.styles.ALL)


today = datetime.now().date()

component = dmc.DatePicker(
    label="DatePicker with date objects",
    value=today,
    disabledDates=[today + timedelta(days=1), today + timedelta(days=3)],
    m="lg"
)

component2 = dmc.DatePicker(
    label="DatePicker with date strings",
    value="2024-11-05",
    disabledDates=["2024-11-04", "2024-11-06"],
    m="lg"

)

app.layout = dmc.MantineProvider([
    dmc.Title("dmc.DatePicker with disabled dates"),
    component,
    component2,
])

if __name__ == "__main__":
    app.run(debug=True)