Playground

Range calendar

A month grid for picking a start and an end date.

  • Built on native elements
  • role="grid" with column headers; one day is in the tab order (roving tabindex).
  • Enter or Space on a day sets the start, then the end; Escape while picking clears the start.
  • Arrow keys move by day and week, Home/End to the start and end of the week, PageUp/PageDown by month; arrows are mirrored in right-to-left.
  • Styles in one file: calendar.css

Import

import '@monoline/css';
import {RangeCalendar} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add range-calendar

Usage

import {RangeCalendar} from '@monoline/react';

<RangeCalendar weekStartsOn={1} />

Examples

Basic

With limits and blocked days

Weekends are blocked; only the next 60 days can be chosen.

Props

RangeCalendarProps

PropTypeDefaultDescription
valueDateRange–The selected range when controlled. Pair with `onValueChange`.
defaultValueDateRangeEMPTYThe initially selected range when uncontrolled. Default empty.
onValueChange((range: DateRange) => void)–Called after every pick. The first pick gives `{start, end: null}`; the second completes the range.
weekStartsOn0 | 10First day of the week: 0 = Sunday, 1 = Monday. Default 0.
minDate–Earliest selectable date; earlier days are disabled.
maxDate–Latest selectable date; later days are disabled.
isDateDisabled((date: Date) => boolean)–Return true for a day that cannot be picked, such as a holiday.
localestring–BCP 47 locale for month and day names.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

AttributeStylesheet
[aria-pressed="true"]calendar.css
[data-outside]calendar.css
[data-today]calendar.css
[aria-pressed="true"]range-calendar.css
[data-in-range]range-calendar.css
[data-preview]range-calendar.css
[data-range-start]range-calendar.css

CSS classes

ClassStylesheet
.calendarcalendar.css
.calendar-daycalendar.css
.calendar-gridcalendar.css
.calendar-headcalendar.css
.calendar-navcalendar.css
.calendar-titlecalendar.css
.calendar-dayrange-calendar.css
.range-calendarrange-calendar.css
.range-cellrange-calendar.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.calendar {
  border-color: var(--accent);
}
.calendar[aria-pressed="true"] {
  background: var(--wash);
}

Accessibility

  • role="grid" with column headers; one day is in the tab order (roving tabindex).
  • Enter or Space on a day sets the start, then the end; Escape while picking clears the start.
  • Arrow keys move by day and week, Home/End to the start and end of the week, PageUp/PageDown by month; arrows are mirrored in right-to-left.
  • The days between start and focus are previewed while picking, by hover and by keyboard.
  • Each day button has a full date name; start and end have aria-pressed; a status region announces the chosen range.
  • Disabled days (min, max, isDateDisabled) are real disabled buttons.

Keyboard

KeysAction
Enter / SpaceOn a day sets the start, then the end
EscapeWhile picking clears the start
Arrow keysMove by day and week
Home / EndTo the start and end of the week
PageUp / PageDownBy month