Lucca
1
Hello, I want to create a datepicker where only tuesdays are selectable.
Like in this example of the Documentation
How can I do something like that? For now I have a callback where I verify if selected date is tuesday, but its not the best choice.
Thanks
Hi @Lucca and welcome to the Dash community 
Dash doesnβt typically accept functions as props, but that is a feature request for dash-mantine-components.
In the meantime, you can use the disabledDates
prop to pass in a list of disabled dates. Here is an example:
1 Like
Hi @AnnMarieW, what if I want to disable special days like Friday instead of hard code date?
Hi @hoatran
You can create a function if Python to generate a list of Fridays to exclude:
from dash import Dash
import dash_mantine_components as dmc
from datetime import date, timedelta
def get_fridays(start_date, num_days=365):
return [
(start_date + timedelta(days=i)).isoformat()
for i in range(num_days)
if (start_date + timedelta(days=i)).weekday() == 4 # 4 represents Friday
]
component = dmc.DatePickerInput(
label="Select a day other than Fridays",
value=date.today(),
minDate=date.today(),
maxDate=date.today() + timedelta(days=365),
disabledDates=get_fridays(date.today())
)
app = Dash(external_stylesheets=dmc.styles.ALL)
app.layout = dmc.MantineProvider(
component
)
if __name__ == "__main__":
app.run(debug=True)
1 Like
Hi @hoatran
As of DMC V2.0, Itβs now possible to use functions when setting disabled dates. See the example here: