<div class="datepicker"> <div class="datepicker-header"> <button class="datepicker-nav-btn">←</button> <button class="datepicker-title-btn" type="button">May 2020</button> <button class="datepicker-nav-btn">→</button> </div> <div class="datepicker-view-container"> <div class="datepicker-month"> <span class="datepicker-day-name">Mon</span> <span class="datepicker-day-name">Tue</span> <span class="datepicker-day-name">Wed</span> <span class="datepicker-day-name">Thu</span> <span class="datepicker-day-name">Fri</span> <span class="datepicker-day-name">Sat</span> <span class="datepicker-day-name">Sun</span> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">27</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">28</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">29</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">30</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">1</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">2</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">3</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">4</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">5</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">6</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">7</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">8</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">9</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">10</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">11</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">12</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">13</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">14</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">15</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">16</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">17</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">18</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">19</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">20</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">21</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">22</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">23</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">24</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">25</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">26</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">27</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">28</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">29</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">30</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">31</span> </button> </div> </div> </div>
As you can see, we wrapped our Datepicker
with a purely UI component DatepickerContainer
. This is a recommended way to display your Datepicker.
In the example below, we are taking control over the displayed value by passing value
and onDateChange
prop. You onChange shuld accept date as a single param.
MonTueWedThuFriSatSun | <DatepickerContainer> <Datepicker value={value1} onDateChange={setValue1} /> </DatepickerContainer> <div class="datepicker-container"> <div class="datepicker"> <div class="datepicker-header"> <button class="datepicker-nav-btn">←</button> <button class="datepicker-title-btn" type="button">May 2020</button> <button class="datepicker-nav-btn">→</button> </div> <div class="datepicker-view-container"> <div class="datepicker-month"> <span class="datepicker-day-name">Mon</span> <span class="datepicker-day-name">Tue</span> <span class="datepicker-day-name">Wed</span> <span class="datepicker-day-name">Thu</span> <span class="datepicker-day-name">Fri</span> <span class="datepicker-day-name">Sat</span> <span class="datepicker-day-name">Sun</span> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">27</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">28</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">29</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">30</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">1</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">2</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">3</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">4</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">5</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">6</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">7</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">8</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">9</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">10</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">11</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">12</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">13</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">14</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month datepicker-day-selected datepicker-day-selected-first datepicker-day-selected-last"> <span class="datepicker-day-content">15</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">16</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">17</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">18</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">19</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">20</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">21</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">22</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">23</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">24</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">25</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">26</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">27</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">28</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">29</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">30</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">31</span> </button> </div> </div> </div> </div> <br /> <br /> <button class="btn btn-sm" type="button" role="button">Selected Date: 5/15/2020</button> ReactHTML Snippet |
You can limit the date selection by passing minDate
, maxDate
or both. The days which do not fit in the range will be disabled.
MonTueWedThuFriSatSun | <DatepickerContainer> <Datepicker value={value3} onDateChange={setValue3} minDate={new Date(currentYear, currentMonth, 5)} maxDate={new Date(currentYear, currentMonth, 25)} /> </DatepickerContainer> <div class="datepicker-container"> <div class="datepicker"> <div class="datepicker-header"> <button class="datepicker-nav-btn">←</button> <button class="datepicker-title-btn" type="button">May 2020</button> <button class="datepicker-nav-btn">→</button> </div> <div class="datepicker-view-container"> <div class="datepicker-month"> <span class="datepicker-day-name">Mon</span> <span class="datepicker-day-name">Tue</span> <span class="datepicker-day-name">Wed</span> <span class="datepicker-day-name">Thu</span> <span class="datepicker-day-name">Fri</span> <span class="datepicker-day-name">Sat</span> <span class="datepicker-day-name">Sun</span> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">27</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">28</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">29</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">30</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">1</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">2</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">3</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">4</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">5</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">6</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">7</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">8</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">9</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">10</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">11</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">12</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">13</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">14</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">15</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">16</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">17</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">18</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month datepicker-day-selected datepicker-day-selected-first datepicker-day-selected-last"> <span class="datepicker-day-content">19</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">20</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">21</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">22</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">23</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">24</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">25</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">26</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">27</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">28</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">29</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">30</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">31</span> </button> </div> </div> </div> </div> <br /> <br /> <button class="btn btn-sm" type="button" role="button">Selected Date: 5/19/2020</button> ReactHTML Snippet |
You can allow range selection with isRange
prop. As a value (and onChange param), you should pass an DatepickerRangeValue = { from?: Date, to?: Date }
MonTueWedThuFriSatSun | <DatepickerContainer> <Datepicker isRange value={value2} onDateChange={setValue2} /> </DatepickerContainer> <div class="datepicker-container"> <div class="datepicker"> <div class="datepicker-header"> <button class="datepicker-nav-btn">←</button> <button class="datepicker-title-btn" type="button">May 2020</button> <button class="datepicker-nav-btn">→</button> </div> <div class="datepicker-view-container"> <div class="datepicker-month"> <span class="datepicker-day-name">Mon</span> <span class="datepicker-day-name">Tue</span> <span class="datepicker-day-name">Wed</span> <span class="datepicker-day-name">Thu</span> <span class="datepicker-day-name">Fri</span> <span class="datepicker-day-name">Sat</span> <span class="datepicker-day-name">Sun</span> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">27</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">28</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">29</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">30</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">1</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">2</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">3</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">4</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">5</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">6</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">7</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month datepicker-day-selected datepicker-day-selected-first"> <span class="datepicker-day-content">8</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month datepicker-day-selected"> <span class="datepicker-day-content">9</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month datepicker-day-selected"> <span class="datepicker-day-content">10</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month datepicker-day-selected"> <span class="datepicker-day-content">11</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month datepicker-day-selected"> <span class="datepicker-day-content">12</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month datepicker-day-selected"> <span class="datepicker-day-content">13</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month datepicker-day-selected"> <span class="datepicker-day-content">14</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month datepicker-day-selected"> <span class="datepicker-day-content">15</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month datepicker-day-selected"> <span class="datepicker-day-content">16</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month datepicker-day-selected"> <span class="datepicker-day-content">17</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month datepicker-day-selected"> <span class="datepicker-day-content">18</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month datepicker-day-selected datepicker-day-selected-last"> <span class="datepicker-day-content">19</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">20</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">21</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">22</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">23</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">24</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">25</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">26</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">27</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">28</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">29</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">30</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">31</span> </button> </div> </div> </div> </div> ReactHTML Snippet |
You can change the initial visible month by passing initialVisibleDate
. If you don't, this will be determined based on value
or current date.
MonTueWedThuFriSatSun | <DatepickerContainer> <Datepicker initialVisibleDate={new Date(2222, 1, 1)} /> </DatepickerContainer> <div class="datepicker-container"> <div class="datepicker"> <div class="datepicker-header"> <button class="datepicker-nav-btn">←</button> <button class="datepicker-title-btn" type="button">February 2222</button> <button class="datepicker-nav-btn">→</button> </div> <div class="datepicker-view-container"> <div class="datepicker-month"> <span class="datepicker-day-name">Mon</span> <span class="datepicker-day-name">Tue</span> <span class="datepicker-day-name">Wed</span> <span class="datepicker-day-name">Thu</span> <span class="datepicker-day-name">Fri</span> <span class="datepicker-day-name">Sat</span> <span class="datepicker-day-name">Sun</span> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">28</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">29</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">30</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">31</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">1</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">2</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">3</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">4</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">5</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">6</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">7</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">8</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">9</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">10</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">11</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">12</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">13</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">14</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">15</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">16</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">17</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">18</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">19</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">20</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">21</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">22</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">23</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">24</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">25</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">26</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">27</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">28</span> </button> <button type="button" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">1</span> </button> <button type="button" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">2</span> </button> <button type="button" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">3</span> </button> </div> </div> </div> </div> ReactHTML Snippet |
By default, Monday is a first weekday. You can change this by passing weekdayOffset
prop. See example below starting with Sunday.
SunMonTueWedThuFriSat | <DatepickerContainer> <Datepicker weekdayOffset={1} /> </DatepickerContainer> <div class="datepicker-container"> <div class="datepicker"> <div class="datepicker-header"> <button class="datepicker-nav-btn">←</button> <button class="datepicker-title-btn" type="button">May 2020</button> <button class="datepicker-nav-btn">→</button> </div> <div class="datepicker-view-container"> <div class="datepicker-month"> <span class="datepicker-day-name">Sun</span> <span class="datepicker-day-name">Mon</span> <span class="datepicker-day-name">Tue</span> <span class="datepicker-day-name">Wed</span> <span class="datepicker-day-name">Thu</span> <span class="datepicker-day-name">Fri</span> <span class="datepicker-day-name">Sat</span> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">26</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">27</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">28</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">29</span> </button> <button type="button" disabled="" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">30</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">1</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">2</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">3</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">4</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">5</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">6</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">7</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">8</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">9</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">10</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">11</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">12</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">13</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">14</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">15</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">16</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">17</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">18</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">19</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">20</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">21</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">22</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">23</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">24</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">25</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">26</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">27</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">28</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">29</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">30</span> </button> <button type="button" class="datepicker-day datepicker-day-current-month"> <span class="datepicker-day-content">31</span> </button> <button type="button" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">1</span> </button> <button type="button" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">2</span> </button> <button type="button" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">3</span> </button> <button type="button" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">4</span> </button> <button type="button" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">5</span> </button> <button type="button" class="datepicker-day datepicker-day-not-current"> <span class="datepicker-day-content">6</span> </button> </div> </div> </div> </div> ReactHTML Snippet |
Anywhere the datepicker renders text, you can replace it by passing formatters. Your formatters can return plain string or ReactNode as well.
renderTitle | (visibleDate: Date, activeView: DatepickerView) => React.ReactNode |
renderMonthName | (monthNumber: number) => React.ReactNode |
renderWeekdayShort | (weekdayNumber: number) => React.ReactNode |
value | Required: false |
type: DatepickerValue | |
Pass "Date" or object with from and to if you are using isRange |
onDateChange | Required: false |
type: (value: DatepickerValue) => void | |
This gives you the ability to handle the date selection. |
isRange | Required: false |
type: boolean | |
Enables date range selection |
minDate | Required: false |
type: Date | |
A minimum date that can be selected. The rest is disabled. |
maxDate | Required: false |
type: Date | |
A maximum date that can be selected. The rest is disabled. |
initialVisibleDate | Required: false |
type: Date | |
A date to determine initial visible month. If not provided, initial display month will be determined based on value prop or current date. |
weekdayOffset | Required: false |
type: number | default value: 0 |
Allows you to change starting weekday. 0 is Monday, 1 is Sunday. |
Value varies based on the isRange
prop.
DatepickerSimpleValue | Date | if isRange is false |
DatepickerRangeValue | {from ?: Date, to?: Date } | if isRange is true |