Live demo
Demo source
Use a calendar when people choose dates and benefit from seeing the month,
such as a delivery day or a stay. It selects one date, or a start and end date
with selectionType="range". To enter a date in a form, a
date field opens the same calendar from an
input.
Anatomy
A June 2025 calendar showing a range from the 3rd to the 12th. Callouts mark 1 the month and year controls, 2 the grid of days and week numbers, and 3 the shortcuts below the grid.
- Date controls choose the month and year and step between months.
- Grid shows the days. Selected days, today, days outside the month and
disabled days are styled differently.
showWeekNumbersadds a week column, andfirstDayOfWeeksets the first column. - Controls (optional) hold
shortcutsfor common dates, andshowActionsadds cancel and confirm buttons.
Themes
The design includes Spark and Ocean appearances. Use the page's theme and mode controls to compare the live examples; retain the same labels, states and validation messages in each theme.
Values and limits
The value is a string in dateFormat (YYYY-MM-DD by default), or two dates
separated by a comma for a range. min, max and disabledDates make days
unavailable. numberOfCalendars shows up to four months side by side; the
design illustrates one month for compact choices and two for ranges.
Calendar options
| Design option | Code configuration |
|---|---|
| One date or a range | selectionType="single" or selectionType="range" |
| One or two visible months | numberOfCalendars="1" or numberOfCalendars="2" |
| Week numbers | showWeekNumbers |
| Start of the week | firstDayOfWeek, from 0 (Sunday) to 6 (Saturday) |
| Language and formatting | locale for month/day labels; dateFormat for date strings |
| Controls below, left or right | shortcutsPlacement="bottom", "left" or "right" |
| Common dates or periods | shortcuts, with a label and singleValue or rangeValue |
| Cancel and confirm actions | showActions, with cancelLabel and primaryLabel |
Keep date formats consistent with the surrounding form. Choose shortcuts that reflect real tasks, such as the current reporting period.
Accessibility
The design specifies keyboard access to date selection. In this version,
day cells are clickable div elements without keyboard handlers or tab
stops, so the standalone calendar does not yet meet that requirement. Keep
a typed date field or
date range field available when people
must enter a date without a pointer.
Guidelines
- Offer a few shortcuts for dates people choose often; don't overload the controls.
- Explain why days are unavailable near the calendar.