- Docs
- Components
- Dates
Range calendar
A Calendar that chooses a range: two picks, a band between them, every step announced.
- Import
- @qeetrix/react/experimental
- Status
- ExperimentalSince 0.0.6
- Renders
<table role="grid">Server-rendered- Tested
- WCAG 2.2 AAaxe on every pull request
01
Import
// Experimental: from the package's experimental entry, until it's stable.
import { RangeCalendar } from "@qeetrix/react/experimental";02
Props
And every native attribute of the element it renders.
| Prop | Type | Default | What it does |
|---|---|---|---|
value · defaultValue | DateRange | null | null | { start, end }, "YYYY-MM-DD"; end never before start. |
onValueChange | (value: DateRange) => void | — | Called once both ends are chosen. |
min · max · isDateDisabled | … | — | As Calendar's: a ruled-out day can't be an end. |
defaultMonth · locale · today · autoFocus | … | — | As Calendar's. |
disabled · readOnly · messages | … | — | As Calendar's. |
03
Parts
Each part carries a data-slot, for tests and placement.
| data-slot | Element | What it is |
|---|---|---|
range-calendar | <div> | The root: Calendar's parts throughout. |
calendar-cell | <td> | A day's cell: data-range start, middle or end, and aria-selected inside the range. |
04
Count the days
Both ends inclusive: the same day twice is a one-day range.
const days = (range: DateRange) => Math.round((Date.parse(range.end) - Date.parse(range.start)) / 86_400_000) + 1;