Skip to content

Calendar

Calendar

A month calendar for picking one day, without a text input: the grid of DatePicker's dialog, placed in the page (APG date picker grid).

- **Structure**: a role="group" root, named with aria-label/aria-labelledby or by a surrounding Field, around the previous-month button, the month text (a polite live region that labels the grid), the next-month button and a role="grid" table of six weeks, with an optional leading column of week numbers (showWeekNumbers, firstWeekOfYear) and an optional footer button, "Go to today" (showGoToToday), which shows today's month and focuses today without selecting it. The month text is no heading, since a component cannot know the page's heading levels.
- **Month and year views** (showMonthPicker, on by default): the month text is a button (named by that text, its hint labels.chooseMonth) that shows the 12 months of the year; their heading, the year, is a button to the year view, a decade with the year before and after it (muted). The header buttons move by a year, then by a decade. A picked year shows its months and a picked month its days (the focused day keeps its day of the month, clamped); Escape goes back a level to the period shown before. Each view change moves focus into the new grid. Months and years wholly outside minDate/maxDate stay focusable, aria-disabled.
- **Keyboard**: one tab stop in the grid, the focused day (the selected day of the shown month, else today, else the first day of the month in range, which may be unavailable). Arrow keys move by day and week (mirrored in RTL), PageUp/PageDown by month, Shift+PageUp/PageDown by year (the day is clamped to the month), Home/End to the start and end of the week; Enter, Space and a click pick the day. Unavailable days (minDate, maxDate, disabledDates) stay focusable and are aria-disabled. In the month and year views the arrows move by a cell and a row of four, Home/End to the row's ends, PageUp/PageDown by a year (months) or ten (years).
- **Value**: onValueChange fires only when the day changes, with local midnight and details; picking the selected day again does nothing. A value that moves to another month shows that month. The selected day is aria-selected on its gridcell and aria-pressed on its button; today is aria-current="date". With selectionRange a pick selects the day's week, work week (workWeekDays) or month: every available day of it is drawn and marked selected, the value is the picked day, and details.range lists the selected days in order.
- **Marked days and custom content**: markedDates draws a dot in the text colour under the number, sets data-marked and says "marked" in the day's name; renderDay replaces the content of the day button (non-interactive content only) and dayLabel sets its name.
- **Forms and Field**: name/required add a hidden input (ISO yyyy-mm-dd) that resets with its form (to defaultValue); a required calendar that the form reports missing focuses its tab stop. Inside a Field the group takes the label, the description and aria-invalid; it says "required" in its description (labels.required), since a group cannot carry aria-required.
- **Server rendering**: pass locale, and today, initialVisibleDate or a value, so the server and the browser render the same month. Only today marks a day in the server HTML: without it the server HTML marks none and the browser marks today once hydrated. Without any of the three the month shown first comes from the server's clock (development warning).

Examples

Default

SundayMondayTuesdayWednesdayThursdayFridaySaturday
export const Default: Story = {};

Localized

MontagDienstagMittwochDonnerstagFreitagSamstagSonntag
export const Localized: Story = {
  args: {
    'aria-label': 'Kalender',
    locale: 'de-DE',
    firstDayOfWeek: 1,
    defaultValue: new Date(2025, 5, 12),
    labels: {
      previousMonth: 'Voriger Monat',
      nextMonth: 'Nรคchster Monat',
      previousYear: 'Voriges Jahr',
      nextYear: 'Nรคchstes Jahr',
      goToToday: 'Heute',
    },
    showGoToToday: true,
  },
};

Week numbers (ISO)

WeekMondayTuesdayWednesdayThursdayFridaySaturdaySunday
22
23
24
25
26
27
export const WeekNumbersISO: Story = {
  name: 'Week numbers (ISO)',
  args: {
    showWeekNumbers: true,
    firstDayOfWeek: 1,
    firstWeekOfYear: 'first-four-day-week',
  },
};

Marked Days

SundayMondayTuesdayWednesdayThursdayFridaySaturday
export const MarkedDays: Story = {
  args: {
    markedDates: (date: Date) => date.getDate() % 7 === 0,
  },
};

Custom Day Content

SundayMondayTuesdayWednesdayThursdayFridaySaturday
export const CustomDayContent: Story = {
  args: {
    renderDay: (date: Date, defaultContent) =>
      date.getDate() === 25 ? <span>โ˜… {defaultContent}</span> : defaultContent,
    dayLabel: (date: Date, defaultLabel: string) =>
      date.getDate() === 25 ? `${defaultLabel}, holiday` : defaultLabel,
  },
};

Week Selection

MondayTuesdayWednesdayThursdayFridaySaturdaySunday
export const WeekSelection: Story = {
  args: {
    selectionRange: 'week',
    firstDayOfWeek: 1,
    defaultValue: new Date(2025, 5, 11),
  },
};

Work Week Selection

SundayMondayTuesdayWednesdayThursdayFridaySaturday
export const WorkWeekSelection: Story = {
  args: {
    selectionRange: 'work-week',
    defaultValue: new Date(2025, 5, 11),
  },
};

Go To Today

SundayMondayTuesdayWednesdayThursdayFridaySaturday
export const GoToToday: Story = {
  args: {
    showGoToToday: true,
    initialVisibleDate: new Date(2025, 0, 10),
  },
};

Month Picker Off

June 2025
SundayMondayTuesdayWednesdayThursdayFridaySaturday
export const MonthPickerOff: Story = {
  args: {
    showMonthPicker: false,
  },
};

Min Max

SundayMondayTuesdayWednesdayThursdayFridaySaturday
export const MinMax: Story = {
  args: {
    minDate: new Date(2025, 5, 10),
    maxDate: new Date(2025, 6, 20),
    defaultValue: new Date(2025, 5, 18),
  },
};

Controlled

SundayMondayTuesdayWednesdayThursdayFridaySaturday

Selected: Sun Jun 15 2025

export const Controlled: Story = {
  render: function ControlledCalendar(args) {
    const [value, setValue] = useState<Date | null>(new Date(2025, 5, 15));
    return (
      <div>
        {/* The controlled pair is wired after the args on purpose. */}
        <Calendar
          {...args}
          value={value}
          onValueChange={(date, details) => {
            setValue(date);
            args.onValueChange?.(date, details);
          }}
        />
        <p className="mt-2 text-wave-body-1">
          Selected: {value ? value.toDateString() : '(none)'}
          {value && isSameDay(value, TODAY) ? ' (today)' : ''}
        </p>
      </div>
    );
  },
};

In a Field

SundayMondayTuesdayWednesdayThursdayFridaySaturday

Pick the day you arrive.

export const InAField: Story = {
  name: 'In a Field',
  args: { 'aria-label': undefined },
  render: (args) => (
    <Field label="Arrival date" hint="Pick the day you arrive." required>
      <Calendar {...args} />
    </Field>
  ),
};

Props

NameTypeRequiredDefaultDescription
valueDate | nullNo

Controlled selected day (null for none).

defaultValueDate | nullNonull

Initial selected day for uncontrolled usage.

onValueChange(date: Date | null, details: CalendarValueChangeDetails) => voidNo

Called with the new day (local midnight) when the selected day changes: a pick of another day or a form reset (Fluent's onSelectDate fires on every pick). Picking the selected day again does nothing. WaveUI always passes details.

minDateDateNo

Earliest available day (the whole day is included).

maxDateDateNo

Latest available day (the whole day is included).

disabledDates(date: Date) => booleanNo

Returns true for days that cannot be picked (called with local-midnight dates).

firstDayOfWeek0 | 1 | 2 | 3 | 4 | 5 | 6No0

First day of the week (0 = Sunday, 1 = Monday, etc.).

localestringNothe runtime default locale

BCP 47 locale of the month text, the weekday names and the day labels. Pass it when rendering on the server, so the server and the browser render the same text. The grid is Gregorian, as in DatePicker. A tag Intl rejects (the POSIX de_DE, a typo) falls back to the runtime default locale (development warning).

todayDateNothe current date (applied after hydration when not passed)

The day marked as today (aria-current="date"), and the tab stop when no day is selected in the shown month. Without it, the server HTML and the hydration render mark no day and the browser applies the current date once hydrated: pass it when rendering on the server, so the mark is in the HTML.

initialVisibleDateDateNotoday's month

The month shown first when there is no value (Fluent's initialPickerDate), clamped into minDate/maxDate like the value's month and today's.

showMonthPickerbooleanNotrue

Turns the month text into a button that shows the month view (the 12 months of the year), whose heading, the year, is a button to the year view (a decade with the year before and after it). A picked year shows its months and a picked month its days; Escape goes back a level to the period shown before. Fluent's isMonthPickerVisible, here as a drill-down in one pane.

showWeekNumbersbooleanNofalse

Adds a leading column of week numbers: a row header per week (Week 23, from labels.weekNumber) under a header cell named labels.week. The numbers follow firstDayOfWeek and firstWeekOfYear; the column is not focusable and the keys skip it.

firstWeekOfYear'first-day' | 'first-full-week' | 'first-four-day-week'No'first-day'

Which week is week 1 of a year. ISO 8601 is 'first-four-day-week' with firstDayOfWeek={1}.

showGoToTodaybooleanNofalse

Adds a footer button that shows today's month in the day view and focuses today without selecting it. It is disabled while today is outside minDate/maxDate.

markedDates(date: Date) => booleanNo

Days that draw a dot under the number (in the text colour of the day) and say "marked" in their name (labels.markedDay); also data-marked on the day's button (Fluent's getMarkedDays). Called with local-midnight dates.

renderDay(date: Date, defaultContent: React.ReactNode) => React.ReactNodeNo

Replaces the content inside a day's button, which keeps its role, state and keys; defaultContent is the day number. The content must be non-interactive (no buttons or links), and the button's name does not follow it: set the name with dayLabel. The marked-day dot is drawn next to the content.

dayLabel(date: Date, defaultLabel: string) => stringNo

The accessible name of a day, from its default name (the date in words, Monday, June 2, 2025, with labels.markedDay applied for a marked day). Use it to say what renderDay shows.

selectionRange'day' | 'week' | 'work-week' | 'month'No'day'

What a pick selects: the day, or its week, work week (workWeekDays) or month. The value is the picked day, details.range the selected days, and every day of the range is aria-selected, aria-pressed and data-selected. Days that are not available are left out. Fluent's dateRangeType.

workWeekDaysreadonly DayOfWeek[]No[1, 2, 3, 4, 5]

The days of selectionRange="work-week" (0 = Sunday), within the week that starts on firstDayOfWeek.

labelsCalendarLabelsNo

Names of the navigation buttons, the heading button's hints, the "Go to today" button, the week-number column, the marked days and the required hint, for localization.

namestringNo

Form field name: the day is submitted as ISO yyyy-mm-dd (hidden input).

formstringNo

Id of the <form> the value belongs to, when the calendar is outside it.

requiredbooleanNo

Blocks form submission while no day is selected; the form's report focuses the calendar's tab stop. Said in the description (labels.required), as the group cannot carry aria-required. A consumer aria-required alone also shows that hint (assistive technology only: it does not block submission).

refReact.Ref<HTMLDivElement>No

Ref to the root element.

slotProps{ header?: SlotPart<'div'>; previousButton?: SlotPart<'button'>; heading?: SlotPart<'div'>; headingButton?: SlotPart<'button'>; nextButton?: SlotPart<'button'>; grid?: SlotPart<'table'>; weekday?: SlotPart<'th'>; weekNumberHeader?: SlotPart<'th'>; weekNumber?: SlotPart<'th'>; day?: SlotPart<'button'>; markedDot?: SlotPart<'span'>; month?: SlotPart<'button'>; year?: SlotPart<'button'>; footer?: SlotPart<'div'>; todayButton?: SlotPart<'button'> }No

Props for the elements the Calendar draws, by part, merged into each part's own: your classes after the part's (yours win a conflict), your styles over its styles, your handlers before its handlers (preventDefault() in yours skips the Calendar's handling of the event), your ref beside its ref, and your ids added to its aria-labelledby and aria-describedby. Every attribute the Calendar sets on a part is locked and keeps the Calendar's value (set it through its own props); you add the attributes it does not set. A part takes no children. A part of a repeated element (weekday, weekNumber, day, markedDot, month, year) reaches each of them, and one ref holds the last one attached. A part of an element the shown view does not draw is ignored. Two exceptions to the handler rule: the tab stop always follows a focused cell after your onFocus, and a button that is disabled but stays focusable (a navigation button at a bound, an unavailable day, month or year) does not call your onClick.

Any other prop is passed to the element it renders (HTMLDivElement).

Parts

  • header
  • previousButton
  • heading
  • headingButton
  • nextButton
  • grid
  • weekday
  • weekNumberHeader
  • weekNumber
  • day
  • markedDot
  • month
  • year
  • footer
  • todayButton

Stable class names

PartClass
rootwave-calendar
headerwave-calendar__header
previousButtonwave-calendar__previous-button
headingwave-calendar__heading
headingButtonwave-calendar__heading-button
nextButtonwave-calendar__next-button
gridwave-calendar__grid
weekdaywave-calendar__weekday
weekNumberHeaderwave-calendar__week-number-header
weekNumberwave-calendar__week-number
daywave-calendar__day
markedDotwave-calendar__marked-dot
monthwave-calendar__month
yearwave-calendar__year
footerwave-calendar__footer
todayButtonwave-calendar__today-button