react-datepicker
react-datepicker copied to clipboard
Would you please disable holidays on calendar?
showing holidays and making them disabled is so much useful. I need that in my project, I should handle it in other ways now but having this feature is really helpful, I would appreciate if you add holidays, or make a property like flag, to customize showing holidays in it. thanks
Hello, I'm glad to hear that! To disable specific days, you can use the disabledDate prop. For instance, if you want to disable Fridays, you can achieve this with the following code:
disableDate={(date)=> {
if(date.day() === 5){
return true; // mean this day should be disabled
}
return false;
}}
By the way, you can also change the style of specific days with the following code
dayEffects={[
{
day: '2022-09-12',
color: 'red',
dotColor: 'red',
title: 'What ever you want',
},
]}
I got that, thank you. But in this way, for example, I should have list of holidays of a year and check each day if it is included in holidays to disable them, if the calendar could handle it using a prop like "disableHolidays", it would be better and the code where it's used would be cleaner.
Well, that's a good idea, but please consider that we have about 200 countries with different holidays.
if lang={'fa'} could use this option: disableHolidays ={true}