react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

Would you please disable holidays on calendar?

Open SomayehAmiri76 opened this issue 1 year ago • 4 comments

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

SomayehAmiri76 avatar Dec 10 '23 07:12 SomayehAmiri76

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',
        },
      ]}

ijavad805 avatar Dec 11 '23 09:12 ijavad805

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.

SomayehAmiri76 avatar Dec 11 '23 09:12 SomayehAmiri76

Well, that's a good idea, but please consider that we have about 200 countries with different holidays.

ijavad805 avatar Dec 11 '23 10:12 ijavad805

if lang={'fa'} could use this option: disableHolidays ={true}

Arcadio-1 avatar Jan 31 '24 16:01 Arcadio-1