Calendar
Unstyled Gregorian date selection supporting single, multiple, and range modes, localized weekdays, and composable caption controls.
Base Calendar is an unstyled Gregorian calendar supporting single (default), multiple, and range selection modes. Dates use YYYY-MM-DD and the visible month uses YYYY-MM, with independent controlled state for both selection and month.
Preview
Section titled “Preview”Base calendar with month and year caption composition:
Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases.
Anatomy
Section titled “Anatomy”Compose ten parts: Root, Caption, Heading, Previous, Next, Grid, Weekdays, Weekday, Row, and Day.
- Place seven
Weekdayparts (offset0–6) insideWeekdays, and up to six indexedRowparts (index0–5) containingDayparts (offset0–41) insideGrid. - By default, Calendar renders only the 4, 5, or 6 weeks needed for the visible month; set
fixedWeeks={true}to always reserve six weeks. Unused rows and day cells are hidden and excluded from focus. - Weekday labels and date ordering follow
weekStartsOn(0= Sunday) andlocale.direction="rtl"mirrors Left/Right arrow navigation.
Selection modes and controlled state
Section titled “Selection modes and controlled state”- Single (
single): controlled viavalue/defaultValue(YYYY-MM-DD); emitsonValueChange({ value }). - Multiple (
multiple): controlled viavalues/defaultValues(deduplicated, sorted date array); emitsonValuesChange({ values }). Constrain selection size withminSelectedandmaxSelected. - Range (
range): controlled viarange/defaultRange({ from?, to? }); emitsonRangeChange({ range }). The first click sets{ from }, the second completes an ordered inclusive{ from, to }, and{}clears it. UseminNights/maxNightsto constrain the interval between endpoints (minNights=0allows a same-day range).
min, max, and Root unavailable apply across all modes. A range crossing an unavailable date is rejected while keeping its start anchor. readOnly disables selection while still allowing month navigation.
Clock and caption composition
Section titled “Clock and caption composition”- Calendar never reads the system clock directly: pass
todayas aYYYY-MM-DDstring to mark the current day (aria-current="date"). - Initial visible month resolves in order:
month→defaultMonth→ active mode’s selected date →today→1970-01. - For month/year dropdowns, compose real family Select controls inside
Captionand wire them withbindCalendarCaption(source, { month, year })using Calendar’s public month state andrequestMonth(calldispose()on teardown).
Exposed state and methods
Section titled “Exposed state and methods”Rootexposesmode,weekCount,selectedCount,rangeComplete, plusrequestMonth,requestValue(date),requestValues(dates),requestRange(range),getValues(), andgetRange().Dayexposesselected,rangeStart,rangeEnd,rangeMiddle, andrangePending.Gridsetsaria-multiselectableinmultipleandrangemodes.
Root Props
Section titled “Root Props”Pass value, values, range, or month to control the matching state.
| Prop | Type | Default |
|---|---|---|
mode | 'single' 'multiple' 'range' | single |
value | string | undefined |
values | readonly string[] | undefined |
defaultValues | readonly string[] | [] |
range | CalendarRange | undefined |
defaultRange | CalendarRange | {} |
minSelected / minNights | number | 0 |
maxSelected / maxNights | number | undefined |
defaultValue | string | '' |
defaultMonth | string | undefined |
min | string | '' |
max | string | '' |
unavailable | string[] | [] |
disabled | boolean | false |
readOnly | boolean | false |
weekStartsOn | number | 0 |
fixedWeeks | boolean | false |
a11yLabel | string | Calendar |
today | string | '' |
locale | string | en-US |
direction | 'ltr' 'rtl' | ltr |
Other parts
Section titled “Other parts”- Day:
datedefaults to'',offsetto0, anddisabledtofalse. - Row:
index(no default). - Caption:
a11yLabeldefaults to'Calendar navigation'. - Previous / Next: accept Button props;
a11yLabeldefaults to'Previous month'and'Next month'. - Weekday:
offsetdefaults to0. - Grid, Heading, Weekdays: no props.