View as Markdown

Calendars

Calendar

An inline month, year and decade calendar with single or multiple selection, bounds, disabled days, custom day cells, week numbers, calendar systems and the APG date grid keyboard model.

Calendar is an inline calendar: a header with previous and next buttons and a view button, and a grid of days (or months, or years). It lives in @salmonui/calendars/calendar together with RangeCalendar and has its own stylesheet.

import { Calendar } from '@salmonui/calendars/calendar';
import '@salmonui/calendars/calendar/styles.css';

export function DeliveryDate() {
  return <Calendar aria-label="Delivery date" locale="en-US" defaultValue="2026-11-23" onValueChange={(date) => console.log(String(date))} />;
}

Values are plain ISO dates (PlainDate: frozen { year, month, day } with toString() and toJSON() returning YYYY-MM-DD), never Date objects. See Values, time zones and globalization.

Calendar with week numbers and today button

Open demo

An inline Calendar with single selection, ISO week-number row headers, the today button and the view and focused-date callbacks.

WkSunMonTueWedThuFriSat
451234567
46891011121314
4715161718192021
4822232425262728
492930
50

Selected: 2026-11-23 (default) · view month · focused 2026-11-23

Value and selection

value / defaultValue / onValueChange is the controlled and uncontrolled triad of every Salmon UI component. The input accepts a DateInput (date fields, an ISO string, a Temporal.PlainDate or a Date) and onValueChange(value, details) receives a PlainDate (or null); details carries source ('pointer' | 'keyboard' | 'api'), reason ('select' | 'today') and iso, the form value. The callback fires for user changes only; a new value prop never echoes back.

With selectionMode="multiple" the value is an array: clicking a day or pressing Enter / Space toggles it, and onValueChange receives the sorted PlainDate[].

const [dates, setDates] = useState<readonly DateInput[]>([]);
<Calendar selectionMode="multiple" value={dates} onValueChange={setDates} />;

There are no addDate() / removeDate() methods: update the array you pass as value (setDates([...dates, d]), or a filter to remove one).

Multiple dates, bounds and outside days

Open demo

selectionMode="multiple" with a controlled array of dates, min and max bounds, Monday as the first day of the week, narrow weekday headers and visible outside days.

MTWTFSS
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

3 days: 2026-11-10, 2026-11-12, 2026-11-19

Bounds and disabled days

min and max (DateInput) disable every day outside the range: those days are aria-disabled, the previous / next buttons are disabled at the bounds and keyboard focus is clamped. The calendar is unbounded by default (set, for example, min="1900-01-01" max="2099-12-31" to bound it).

isDateDisabled(date) disables single days (weekends, holidays). Disabled days stay focusable so keyboard users can move through them, but they cannot be selected.

<Calendar isDateDisabled={(date) => isWeekend(date) || holidays.has(String(date))} />

Custom day cells

renderDay(ctx) replaces the content of a day cell and getDayProps(ctx) adds a className, style, title or data-* attributes. Both are called only for the cells that are rendered. ctx carries date, selected, disabled, outside, today, focused, inRange, rangeStart and rangeEnd.

<Calendar
  getDayProps={({ date }) => (paydays.has(String(date)) ? { className: 'payday', title: 'Payday' } : undefined)}
  renderDay={({ date }) => <>{date.day}{paydays.has(String(date)) ? ' •' : null}</>}
/>

showOutsideDays shows the days of the previous and next month in the six week grid (hidden by default); they carry data-outside and are selectable.

Disabled days, custom cells, month picker and calendar systems

Open demo

isDateDisabled for weekends and holidays, renderDay and getDayProps for marked days, a month picker through granularity, and the Buddhist and Islamic (Umm al-Qura) calendars with RTL.

SunMonTueWedThuFriSat
12345
6789101112
13141516171819
20212223242526
2728293031
JanFebMarApr
MayJunJulAug
SepOctNovDec
อาจอพพฤศส
1234567
891011121314
15161718192021
22232425262728
2930
حنثرخجس
١٢٣٤
٥٦٧٨٩١٠١١
١٢١٣١٤١٥١٦١٧١٨
١٩٢٠٢١٢٢٢٣٢٤٢٥
٢٦٢٧٢٨٢٩

Views

The header's view button shows the month heading; activating it moves up a view: month → year (12 months) → decade (12 years, including one edge year on each side). Activating a cell in a higher view moves back down.

Prop Meaning
view / defaultView / onViewChange The navigation view: 'month', 'year' or 'decade'.
granularity What is selected: 'day' (default), 'month' (a month picker, value on day 1) or 'year' (value on January 1); it also sets the deepest view.
minView / maxView The deepest view (default from granularity) and the highest view the heading can reach (default 'decade').
focusedValue / defaultFocusedValue / onFocusedValueChange The date the calendar shows and focuses; changes by buttons and keys fire onFocusedValueChange.

The previous and next buttons are labelled through localeText (previousMonth, nextMonth, previousYear, nextYear, previousDecade, nextDecade).

Weeks

  • firstDayOfWeek (0 Sunday ... 6 Saturday) defaults to the locale's week info (Intl.Locale#getWeekInfo(), with a CLDR region fallback and the -u-fw- extension), as the Data Grid date editor does.
  • showWeekNumbers adds a labelled week-number row header to each week.
  • weekRule ('firstDay', 'firstFullWeek' or 'firstFourDayWeek') decides which week of January is week 1; the default comes from the locale's minimal days (4 in most of Europe, the ISO rule).
  • weekdayFormat ('narrow', 'short' or 'long', default 'short') sets the column header width. A two-letter width ("Su") is not offered because Intl does not expose it.

Calendar systems

calendar takes an Intl calendar id; the default is the -u-ca- extension of locale, else Gregorian. Gregorian-month calendars (buddhist, japanese, roc) relabel the era and year; Islamic calendars (islamic-umalqura, islamic-civil, ...) lay out their own months, found by formatting days through Intl, with no calendar tables. The value is an ISO date in every case.

<Calendar locale="ar-SA" calendar="islamic-umalqura" defaultValue="2026-11-23" />

Today

showTodayButton renders a Today button that selects and focuses today; it is disabled when today is out of range or disabled. Today carries data-today and aria-current="date". Both are applied after hydration: the server never computes "today", so its markup does not depend on its clock or time zone. A calendar with no value, defaultValue, focusedValue or defaultFocusedValue renders a sized frame with aria-busy="true" on the server and shows the current month after hydration; pass defaultFocusedValue for a complete server render.

Keyboard

The grid follows the WAI-ARIA APG Date Picker Dialog grid: role="grid" labelled by the heading, weekday headers with their long names as abbr, aria-selected, aria-disabled, aria-current="date", the full date as each day's accessible name, and a roving tabindex (one focusable cell) instead of aria-activedescendant.

Key Month view Year and decade views
Left / Right Previous / next day (mirrored in RTL) Previous / next cell (mirrored in RTL)
Up / Down Same day of the previous / next week Cell above / below
Home / End First / last day of the week First / last cell of the row
Ctrl+Home / Ctrl+End First / last day of the month First / last cell
PageUp / PageDown Previous / next month Previous / next year or decade
Shift+PageUp / Shift+PageDown Previous / next year –
Ctrl+Up / Ctrl+Down Higher / deeper view Higher / deeper view
Enter / Space Select (toggle in multiple mode) Select in the deepest view, else drill down

Direction comes from the inherited dir (or the dir prop) and is read at key time, so RTL mirrors Left and Right without a prop.

Styling

Every part has a .salmon-calendar__* class: __header, __nav, __heading, __grid, __weekday, __week-number, __day (month view), __cell (year and decade views) and __today. State is exposed as data attributes on .salmon-calendar__day: data-selected, data-today, data-outside, data-disabled, data-in-range, data-range-start and data-range-end. Colors come from the theme's --salmon-* variables, so the calendar follows the theme's colorScheme (light, dark or auto) with no calendar-specific theme input; under forced-colors the selection, focus, today and disabled states use system colors, and under pointer: coarse day cells grow to 44 px targets.

API reference

The API reference for @salmonui/calendars/calendar lists every prop, method and type.