Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Calendar with Multiple Day Selection for React

A calendar that starts with the 6th, the 15th, and the 24th of this month selected, so several days can be chosen at once.

Three days start selected: the 6th, the 15th, and the 24th of this month. One month is on screen. Another click adds a day or drops one from that list.

Use it for dates that are not a continuous stretch, such as several shifts. A start and an end belong in a range. A field that opens this grid is a Date Picker. In React, Base UI does not know which days matter.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
Use email insteadNo credit card

Anatomy

Calendar anatomy: prev trigger, month select, year select, next trigger, table, table cell

Usage

<Calendar
  className="rounded-md border"
  mode="multiple"
  onSelect={setDates}
  selected={dates}
/>

FAQ

How do I read the selected days?

mode="multiple" makes selected an array of dates and onSelect the setter. This demo starts with the 6th, the 15th and the 24th of the current month.

Which days start selected?

The 6th, the 15th and the 24th of the current month. State starts as those three dates, and the calendar renders the list its change handler returns.

What wraps the grid?

The Calendar className is rounded-md border. Several days come from the selection prop on that same element.

What does the change handler receive?

onSelect receives the next array of dates, and this demo stores it with setDates.

How are the starting dates built?

selectedDates maps 6, 15 and 24 through new Date(year, month, day).

How many months are on screen?

One. This demo sets no month count, so the grid is a single month with those three days selected.

API Reference

Calendar

Sets mode="multiple", onSelect={setDates} and selected={dates}. The rest is on the Calendar page.