RangeCalendar

Data input

A month calendar to pick a range of dates: bind:value is { start, end } of DateValues (from @limerdev/zest). The first click sets the start, the second the end; the days between are highlighted. minDays, maxDays, minValue, maxValue, isDateUnavailable, numberOfMonths. With no children it draws the header and month grids; its parts are named like Calendar's for custom layouts.

import { RangeCalendar } from '@limerdev/zest';
RangeCalendar for AI tools (llms.txt)
Use for
Picking a period: a report's date range, an absence, a project phase. In a form, DateRangePicker puts it in a popover.
Don't
A single date: use Calendar. Dates people type: use DateRangeField.

Examples

Basic

Click the first and last day of the period.

SuMoTuWeThFrSa
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
SuMoTuWeThFrSa
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6

… – …

Props

Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that renders your own element, with props to spread on it).

RangeCalendar.Root

Prop Type Default Description
calendarLabel string – This label is exclusively used for accessibility, remaining hidden from the page. It's read by screen readers when the calendar is opened. The current month and year are automatically appended to the label, so you only need to provide the base label. For instance: - 'Date of birth' will be read as 'Date of birth, January 2021' if the current month is January 2021. - 'Appointment date' will be read as 'Appointment date, January 2021' if the current month is January 2021. - 'Booking date' will be read as 'Booking date, January 2021' if the current month is January 2021.
disabled boolean false Whether or not the calendar is disabled.
disableDaysOutsideMonth boolean false Whether to disable the selection of days outside the current month. By default, days outside the current month are rendered to fill the calendar grid, but they are not selectable. Setting this prop to true will disable this behavior.
excludeDisabled boolean false Whether to automatically reset the range if any date within the selected range becomes disabled. When true, the entire range will be cleared if a disabled date is found between the start and end dates.
fixedWeeks boolean false Display 6 weeks per month, regardless the month's number of weeks. This is useful for displaying a consistent calendar, where the size of the calendar doesn't change month to month. To display 6 weeks per month, you will need to render out the previous and next month's dates in the calendar as well.
isDateDisabled DateMatcher – A function that receives a date and returns true or false to indicate whether the date is disabled.
isDateUnavailable DateMatcher – Dates matching the provided matchers are marked as "unavailable." Unlike disabled dates, users can still focus and select unavailable dates. However, selecting an unavailable date renders the date picker as invalid. For example, in a calendar for booking appointments, you might mark already booked dates as unavailable. These dates could become available again before the appointment date, allowing users to select them to learn more about the appointment. [data-unavailable] - applied to unavailable dates
locale string 'en' The default locale setting.
maxDays number undefined The maximum number of days that can be selected in a range.
maxValue DateValue – The maximum date that can be selected in the calendar.
minDays number undefined The minimum number of days that can be selected in a range.
minValue DateValue – The minimum date that can be selected in the calendar.
monthFormat "numeric" | "long" | "short" | "narrow" | "2-digit" | ((month: number) => string) "long" The format of the month names in the calendar.
numberOfMonths number 1 Determines the number of months to display on the calendar simultaneously. For navigation between months, refer to the pagedNavigation prop.
onEndValueChange OnChangeFn<DateValue | undefined> – A callback function called when the end value changes. This doesn't necessarily mean the value has updated and should be used to apply cosmetic changes to the calendar when only part of the value is changed/completed.
onPlaceholderChange OnChangeFn<DateValue> – A callback function called when the placeholder value changes.
onStartValueChange OnChangeFn<DateValue | undefined> – A callback function called when the start value changes. This doesn't necessarily mean the value has updated and should be used to apply cosmetic changes to the calendar when only part of the value is changed/completed.
onValueChange OnChangeFn<DateRange> – A callback function called when the value changes.
pagedNavigation boolean false Applicable only when numberOfMonths is greater than 1. Controls whether to use paged navigation for the next and previous buttons in the date picker. With paged navigation set to true, clicking the next/prev buttons changes all months in view. When set to false, it shifts the view by a single month. For example, with pagedNavigation set to true and 2 months displayed (January and February), clicking the next button changes the view to March and April. If pagedNavigation is false, the view shifts to February and March.
placeholder bindable DateValue the current date The placeholder date, used to control the view of the calendar when no value is present.
preventDeselect boolean false Whether or not users can deselect a date once selected without selecting another date.
readonly boolean false Whether the calendar is readonly. When true, the user will be able to focus and navigate the calendar, but will not be able to select dates.
value bindable DateRange – The value of the selected date range.
weekdayFormat "long" | "short" | "narrow" 'short' How the string representation of the weekdays provided via the weekdays state store should be formatted. md - "long": "Sunday", "Monday", "Tuesday", etc. - "short": "Sun", "Mon", "Tue", etc. - "narrow": "S", "M", "T", etc.
weekStartsOn 0 | 1 | 2 | 3 | 4 | 5 | 6 0 (Sunday) The day of the week to start the calendar on, which must be a number between 0 and 6, where 0 is Sunday and 6 is Saturday.
yearFormat "numeric" | "2-digit" | ((year: number) => string) "numeric" The format of the year names in the calendar.

RangeCalendar.Header

No props of its own beyond the common ones.

RangeCalendar.Heading

No props of its own beyond the common ones.

RangeCalendar.PrevButton

No props of its own beyond the common ones.

RangeCalendar.NextButton

No props of its own beyond the common ones.

RangeCalendar.Months

No props of its own beyond the common ones.

RangeCalendar.Grid

No props of its own beyond the common ones.

RangeCalendar.GridHead

No props of its own beyond the common ones.

RangeCalendar.GridBody

No props of its own beyond the common ones.

RangeCalendar.GridRow

No props of its own beyond the common ones.

RangeCalendar.HeadCell

No props of its own beyond the common ones.

RangeCalendar.Cell

Prop Type Default Description
date required DateValue – The date value of the cell.
month required DateValue – The month DateValue that this cell is being rendered in.

RangeCalendar.Day

No props of its own beyond the common ones.