Calendar
A month grid with no date library behind it — single dates or ranges, one or two months.
Loading documentation…
| Mo | Tu | We | Th | Fr | Sa | Su |
|---|---|---|---|---|---|---|
Calendar is the month grid. It is deliberately dependency-free:
Intl.DateTimeFormat already knows every locale's month and weekday names, and
the only arithmetic a calendar needs is "add a day", which Date does
correctly across DST. A date library for this would cost more than the
component.
Everything works on local midnight — storing a time component is how a calendar ends up off by one for anyone east of Greenwich after 23:00.
Calendar is controlled: it owns the month you are looking at, you own the
selection.
mode="range" selects two dates and fills everything between them. The value
is { from, to }, with to staying null until the second click.
min and max set the window; disabledDate adds any rule on top of it —
weekends, holidays, days already booked.
| Mo | Tu | We | Th | Fr | Sa | Su |
|---|---|---|---|---|---|---|
locale drives the month and weekday names through Intl; weekStartsOn is
1 (Monday) by default, because most of the world starts there.
DatePicker is this calendar inside a popover,
with a control that reads the date back.
Both are exported because a calendar's caller always ends up needing them.
It defaults to single.
The selection. { from, to } in range mode.
Fires with the new selection. Selecting the same day again clears it.
How many months side by side. It defaults to 1.
The month shown on first render. It defaults to the selection, or today.
Nothing before min or after max is selectable.
An extra rule on top of min and max.
0 is Sunday, 1 is Monday. It defaults to 1.
Passed to Intl.DateTimeFormat for month and weekday names.
Merged into the grid's container.
The first date in the range.
The last date. It stays null while the range is half-made.