Components

Calendar

Month grids for picking a date, several dates or a range, with room for a price or a fare under each day.

Usage

import { Calendar } from 'nyctoui/calendar'

<Calendar aria-label="Date" defaultValue="2026-12-14" />

Values are ISO date strings such as '2026-12-14', with no time or time zone, so no date library is needed. A range is [start, end] and several dates are a sorted array. Arrow keys move by day and week, Page Up and Page Down by month, and the grid takes one Tab stop.

Without children the calendar renders its navigation and a month for each of months. Write the parts out to add a footer or data under each day. For a field that opens a calendar, use a DatePicker.

Good for

  • A booking page for a hotel or a rental, picking check-in and check-out with the nightly price under each day.
  • A flight search showing the cheapest fare for each date.
  • A time-off request in an HR tool, choosing a range of workdays.
  • A scheduling app, picking the day before choosing a time slot.

Explaining a day

Pass tooltip to a CalendarDay, as text or a function of the day’s state, to say why it can’t be picked. It shows on hover, on keyboard focus and on tap, since a phone has no hover. Days that return nothing show no tooltip. The calendar shares one tooltip between all its days.

<CalendarDay
  value={cell.date}
  tooltip={(day) => day.disabled && !day.unavailable && 'Minimum stay 2 nights'}
/>

Anatomy

<Calendar>
  <CalendarNav />
  <CalendarMonths>
    <CalendarMonth>
      {(cell) => (
        <CalendarDay value={cell.date}>
          {(day) => (
            <>
              {day.label}
              <CalendarDayHint />
            </>
          )}
        </CalendarDay>
      )}
    </CalendarMonth>
  </CalendarMonths>
  <CalendarFooter />
</Calendar>

Examples

Range

mode="range" picks a start, then an end, previewing the range in between. Escape drops an unfinished range. With two months, pageBy="page" turns both at once.

Multiple dates

mode="multiple" toggles each date on its own.

Fixed weeks

fixedWeeks shows six weeks in every month, so the calendar keeps its height as the months turn, in a popup or beside a form. The weeks fill with the days around the month, in a quieter color; picking one turns to its month. Set showOutsideDays={false} to leave them blank.

With a range over two months, both grids keep six weeks. A day the other month already shows stays blank, so each date appears once, and the band breaks where one month ends and the next begins.

Booking with nightly prices

A stay of 2 to 14 nights, priced per night, around nights that are already booked. minDays and maxDays count both ends, so a night count is one less. Booked nights are unavailable: struck through, still focusable, and a range can’t cross them.

A day stands for its night, so a booked day is struck through: no stay can start there. A guest may still check out on the morning another booking starts. While a check-in is picked, onAnchorChange lets the example free the next booked night as a check-out day. Days too close to the check-in for the minimum stay turn gray until it is done.

A day’s tooltip says why it can’t be picked, such as “Minimum stay 2 nights” or “Check-out only”, on hover, keyboard focus and tap.

Fares

One date, with the fare under each day and the lowest ones marked. There are no flights on Tuesdays, and sales stop at max.

Days allowed inside a range

allowUnavailable lets a range run across unavailable days without starting or ending on one, as time off spans a weekend.

Min and max

Days before min and after max can’t take focus, and the arrows stop at their months. Unavailable days, here Sundays, can be focused so screen readers still hear them.

Best practices

Do
  • Set min and max to the window people can actually pick from, like future dates for a booking or the current quarter for a report.
  • Use mode="range" for anything with a start and an end, such as a stay or a leave request, and minDays or maxDays for length rules.
  • Explain why days are unavailable, in a hint under the day or in text near the calendar.
  • Show two months when ranges often cross from one month into the next.
Don’t
  • Use a calendar for a birth date or any date far from today. Typing it is faster; use a date field.
  • Block out long stretches of days with no reason given. People think the calendar is broken.

API reference

Calendar

Holds the value and the months shown. Renders a <div>.

PropTypeDefault
mode
One date, any number of dates, or a range.
'single' | 'multiple' | 'range''single'
value
The selected value, for controlled use.
string | string[] | [string, string] | null—
defaultValue
The starting value, for uncontrolled use.
string | string[] | [string, string] | null—
onValueChange
Called when a date is picked. A range changes once both ends are.
(value, details) => void—
size
Days of 32px, or 40px with room for a CalendarDayHint.
'md' | 'lg''md'
months
How many months show side by side.
number1
pageBy
Whether the arrows turn one month or all of them.
'month' | 'page''month'
month / defaultMonth / onMonthChange
The first month shown, like "2026-12". Defaults to the selected date’s month, else today’s.
string—
min / max
The earliest and latest dates that can be picked.
string—
unavailable
Dates that can’t be picked: dates, { from, to }, { weekday }, { before }, { after }, a function, or a list of these.
DateMatchers—
minDays / maxDays
The shortest and longest range, counting both ends.
number—
allowUnavailable
Lets a range hold unavailable days between its ends.
booleanfalse
onAnchorChange
Called when a range’s start is picked, and with null once the range ends or is dropped.
(anchor: string | null, details) => void—
fixedWeeks
Always shows six weeks, so the height never changes.
booleanfalse
showOutsideDays
Shows the neighboring months’ days at the edges. On with fixedWeeks unless set.
booleanfixedWeeks
weekStartsOn
The first day of the week, 0 for Sunday. Defaults to the locale’s.
number—
locale
The language of the names. Defaults to the page’s.
string—
today
Pins today’s date, which carries a hairline ring.
string—
disabled / readOnly
Disabled takes no focus. Read-only moves focus but picks nothing.
booleanfalse
controller
Drives it from elsewhere. Create one with createCalendarController().
CalendarController—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

CalendarNav

Previous and Next at the ends of the captions, with a hidden heading that announces the month. Renders a <div>.

PropTypeDefault
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

CalendarPrevious / CalendarNext

Ghost icon buttons that turn the months, disabled at min and max. Render a <button>.

PropTypeDefault
aria-label
The accessible name, for another language.
string'Previous month' / 'Next month'
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

CalendarMonths

Lays months side by side and stacks them when there isn’t room. Renders a <div>.

PropTypeDefault
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

CalendarMonth

A month’s caption, weekday names and days. Renders a <table> with the grid role.

PropTypeDefault
offset
Which of the months shown, from 0.
number0
children
Renders the day for each cell.
(cell) => ReactNode—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

CalendarDay

A day. Renders a <td> with the gridcell role.

PropTypeDefault
value
The ISO date, from the cell.
string—
children
Replaces the day of the month. The state has date, label, selected, disabled, unavailable, today and the range flags.
ReactNode | (state) => ReactNode—
tooltip
Text shown on hover, focus and tap, such as why the day can’t be picked. Return nothing for none.
ReactNode | (state) => ReactNode—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

CalendarDayHint

Small text under the date, such as a price. Renders a <span>.

PropTypeDefault
tone
positive marks a good value, such as the lowest fare.
'default' | 'positive''default'
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

CalendarFooter

A row under the months for a summary and actions. Renders a <div>.

PropTypeDefault
sx
StyleX styles merged after the built-in ones.
StyleXStyles—