@react-datepicker/ui
  • 👋Welcome
  • Getting Started
    • Quickstart
  • Documentation
    • 🔨Building your calendar
    • ⏭️Adding months navigation
    • Arrange to weeks
    • 🎨Design & Customizations
    • 📆Range Picker
    • Calendar options
    • 🌍Localization
    • 🗓️Events scheduling
  • UI Components
    • Calendar
    • Datepicker
    • DateRangePicker
  • Group 1
    • Page 1
Powered by GitBook
On this page
  1. Documentation

Arrange to weeks

PreviousAdding months navigationNextDesign & Customizations

Last updated 6 months ago

Most of the date pickers and calendars you see are arranging their days of month by weeks, therefore showing days outside of a month range. What we did is to render the days in a naive way.

react-datepicker's Month object also includes a weeks array that you can render to arrange your grid as weeks. You can later decide weather you want to render days outside of month range, or maybe design them differently, like in line 6

<div className="daysGrid">
  {month.weeks.map((week) => {
    return week.days.map((day) => {
      return (
        <div
          style={{ opacity: day.isInCurrentMonth ? "1" : "0.5" }}
          {...register(month, day)}
        >
          {day.number}
        </div>
      );
    });
  })}
</div>;