Demos

Pick a single date.

Usage

Use a calendar when the day of the week or nearby dates matter, such as booking a blood draw. For a date the reader already knows, like a birthday, a text input is faster. Put the calendar inside a popover when space is tight.

Import it from @workspace/ui/components/calendar. It is built on React DayPicker, so every DayPicker prop works.

Anatomy

  • Calendar — The month grid with navigation.
  • CalendarDayButton — The button for each day. Exported so you can reuse it in a custom components.DayButton.

Notes

  • Set mode to single, multiple, or range. The shape of selected follows the mode.
  • Use disabled to block dates, for example days before today or days with no slots.
  • captionLayout="dropdown" adds month and year dropdowns for dates far from today. The years run from 100 years ago to this year unless you set startMonth and endMonth.

Examples

Range

Set mode="range" to pick a start and end date. numberOfMonths={2} shows two months side by side.

Month and year dropdowns

Set captionLayout="dropdown" to jump between months and years, for example a date of birth.

Disabled dates

Pass a matcher to disabled. Here, past days and Sundays cannot be booked.

In a popover

A date picker: a button opens the calendar, and picking a day closes it.

Props

These are the props you set most often. Unlisted props pass through to DayPicker.

Calendar

PropTypeDefaultDescription
mode"single", "multiple", or "range"—How many dates can be selected.
selectedDate, Date[], or DateRange—The selected date or dates.
onSelect(value) => void—Called when the selection changes.
captionLayout"label", "dropdown", "dropdown-months", or "dropdown-years"labelHow the month caption is shown.
showOutsideDaysbooleantrueShow days from the next and previous month.
disabledMatcher or Matcher[]—Dates that cannot be picked.
buttonVariantButton variantghostVariant of the previous and next buttons.
classNamestring—Classes merged onto the root.