datui
Color scheme

Forms

Calendar

Month grid date picker with month/year pickers, disabled dates, locale-aware labels and optional time. CalendarHeader is its navigation bar.

import { Calendar, CalendarHeader } from "datui";

Playground

<Calendar size="m" weekStartsOn={1} />

Examples

Basic

Limits

disablePast, maxDateTime and shouldDisableDate.

With time

enableTime adds hour and minute pickers and a Done button.

CalendarHeader on its own

Accessibility

  • Each month is a role="grid" named by its month and year; days are buttons named with the full localized date, today has aria-current="date", the selected cell aria-selected.
  • One day is in the tab order. Arrow keys move by day (crossing into the next or previous month), PageUp/PageDown by month, Home/End to the week edges, Enter/Space select.
  • Previous/next month are labelled icon buttons; month and year are labelled native selects (type-ahead and Up/Down work).
  • Weekday names, month names and day labels come from LocaleProvider via Intl; all built-in strings are props.

API

Calendar

Month grid date picker (react-day-picker): month/year pickers, min/max and custom disabled dates, localized through `LocaleProvider`, optional time. Arrow keys move by day (crossing months), PageUp/PageDown by month, Home/End to week edges, Enter/Space select.

PropTypeDefaultDescription
autoFocusbooleanfalseMove focus into the grid (selected day, else today) on mount.
changeHoursLabelstringHours
changeMinutesLabelstringMinutes
changeMonthLabelstring"Month"
changeYearLabelstring"Year"
classNamestring—
defaultValueDatenull
defaultViewDateDatethe value's month, else the current month
disableFutureboolean—
disablePastboolean—
disablePickersbooleanfalsePlain month title instead of month/year pickers.
doneButtonDisabledboolean—
doneButtonShowbooleantrueShow the Done button under the time pickers.
doneButtonTextstringDone
enableTimebooleanfalseAdds hour and minute pickers (not available at size `s`).
maxDateTimeDate—Latest selectable moment; also limits the time pickers on that day.
minDateTimeDate—Earliest selectable moment; also limits the time pickers on that day.
nextMonthIconReactNode—
nextMonthLabelstring"Next month"
onChange((value: Date) => void)—Called with the picked date (keeping the current time of day).
onDoneButtonClick(() => void)—
onViewDateChange((viewDate: Date) => void)—
prevMonthIconReactNode—
prevMonthLabelstring"Previous month"
renderDayContent((date: Date) => ReactNode)—Custom content inside each day button.
shouldDisableDate((date: Date) => boolean)—
showNeighboringMonthbooleanfalseShow the leading/trailing days of neighbouring months.
size"s" | "m"m
valueDate—
viewDateDate—Month shown. Controlled with `onViewDateChange`.
weekStartsOn0 | 1 | 4 | 2 | 3 | 5 | 61First day of the week, 0 = Sunday.

CalendarHeader

Month navigation bar: previous/next arrows and month + year pickers (native selects, localized through `LocaleProvider`). Used inside Calendar and CalendarRange; usable on its own.

PropTypeDefaultDescription
onChange (required)(viewDate: Date) => void—Called with the first day of the newly chosen month.
viewDate (required)Date—Month shown (any day of it).
changeMonthLabelstringMonth
changeYearLabelstringYear
classNamestring—
disablePickersbooleanfalseShow a plain "Month Year" title instead of month and year pickers.
endMonthDate20 years after `viewDate`Latest month offered by the pickers.
nextMonthDisabledbooleanfalse
nextMonthHiddenbooleanfalse
nextMonthIconReactNode<ChevronRightIcon />
nextMonthLabelstringNext month
onNextMonth(() => void)—Overrides the next-arrow action (default: one month forward via `onChange`).
onPrevMonth(() => void)—Overrides the previous-arrow action (default: one month back via `onChange`).
prevMonthDisabledbooleanfalse
prevMonthHiddenbooleanfalse
prevMonthIconReactNode<ChevronLeftIcon />
prevMonthLabelstringPrevious month
startMonthDate100 years before `viewDate`Earliest month offered by the pickers.