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
| Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday |
|---|---|---|---|---|---|---|
export const Default: Story = {};Localized
| Montag | Dienstag | Mittwoch | Donnerstag | Freitag | Samstag | Sonntag |
|---|---|---|---|---|---|---|
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)
| Week | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday |
|---|---|---|---|---|---|---|---|
| 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
| Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday |
|---|---|---|---|---|---|---|
export const MarkedDays: Story = {
args: {
markedDates: (date: Date) => date.getDate() % 7 === 0,
},
};Custom Day Content
| Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday |
|---|---|---|---|---|---|---|
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
| Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday |
|---|---|---|---|---|---|---|
export const WeekSelection: Story = {
args: {
selectionRange: 'week',
firstDayOfWeek: 1,
defaultValue: new Date(2025, 5, 11),
},
};Work Week Selection
| Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday |
|---|---|---|---|---|---|---|
export const WorkWeekSelection: Story = {
args: {
selectionRange: 'work-week',
defaultValue: new Date(2025, 5, 11),
},
};Go To Today
| Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday |
|---|---|---|---|---|---|---|
export const GoToToday: Story = {
args: {
showGoToToday: true,
initialVisibleDate: new Date(2025, 0, 10),
},
};Month Picker Off
| Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday |
|---|---|---|---|---|---|---|
export const MonthPickerOff: Story = {
args: {
showMonthPicker: false,
},
};Min Max
| Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday |
|---|---|---|---|---|---|---|
export const MinMax: Story = {
args: {
minDate: new Date(2025, 5, 10),
maxDate: new Date(2025, 6, 20),
defaultValue: new Date(2025, 5, 18),
},
};Controlled
| Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday |
|---|---|---|---|---|---|---|
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
| Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday |
|---|---|---|---|---|---|---|
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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
value | Date | null | No | Controlled selected day ( | |
defaultValue | Date | null | No | null | Initial selected day for uncontrolled usage. |
onValueChange | (date: Date | null, details: CalendarValueChangeDetails) => void | No | Called with the new day (local midnight) when the selected day changes: a pick of another day or a form reset (Fluent's | |
minDate | Date | No | Earliest available day (the whole day is included). | |
maxDate | Date | No | Latest available day (the whole day is included). | |
disabledDates | (date: Date) => boolean | No | Returns | |
firstDayOfWeek | 0 | 1 | 2 | 3 | 4 | 5 | 6 | No | 0 | First day of the week (0 = Sunday, 1 = Monday, etc.). |
locale | string | No | the 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 |
today | Date | No | the current date (applied after hydration when not passed) | The day marked as today ( |
initialVisibleDate | Date | No | today's month | The month shown first when there is no value (Fluent's |
showMonthPicker | boolean | No | true | 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 |
showWeekNumbers | boolean | No | false | Adds a leading column of week numbers: a row header per week ( |
firstWeekOfYear | 'first-day' | 'first-full-week' | 'first-four-day-week' | No | 'first-day' | Which week is week 1 of a year. ISO 8601 is |
showGoToToday | boolean | No | false | 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 |
markedDates | (date: Date) => boolean | No | Days that draw a dot under the number (in the text colour of the day) and say "marked" in their name ( | |
renderDay | (date: Date, defaultContent: React.ReactNode) => React.ReactNode | No | Replaces the content inside a day's button, which keeps its role, state and keys; | |
dayLabel | (date: Date, defaultLabel: string) => string | No | The accessible name of a day, from its default name (the date in words, | |
selectionRange | 'day' | 'week' | 'work-week' | 'month' | No | 'day' | What a pick selects: the day, or its week, work week ( |
workWeekDays | readonly DayOfWeek[] | No | [1, 2, 3, 4, 5] | The days of |
labels | CalendarLabels | No | 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. | |
name | string | No | Form field name: the day is submitted as ISO | |
form | string | No | Id of the | |
required | boolean | No | Blocks form submission while no day is selected; the form's report focuses the calendar's tab stop. Said in the description ( | |
ref | React.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 ( |
Any other prop is passed to the element it renders (HTMLDivElement).
Parts
headerpreviousButtonheadingheadingButtonnextButtongridweekdayweekNumberHeaderweekNumberdaymarkedDotmonthyearfootertodayButton
Stable class names
| Part | Class |
|---|---|
root | wave-calendar |
header | wave-calendar__header |
previousButton | wave-calendar__previous-button |
heading | wave-calendar__heading |
headingButton | wave-calendar__heading-button |
nextButton | wave-calendar__next-button |
grid | wave-calendar__grid |
weekday | wave-calendar__weekday |
weekNumberHeader | wave-calendar__week-number-header |
weekNumber | wave-calendar__week-number |
day | wave-calendar__day |
markedDot | wave-calendar__marked-dot |
month | wave-calendar__month |
year | wave-calendar__year |
footer | wave-calendar__footer |
todayButton | wave-calendar__today-button |