Date Range Picker
Two segmented date fields in one frame with a two-month calendar behind a trigger, for a start and an end date that the reader can type or choose.
Type both dates or choose them from the calendar.
import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';export default function DateRangePickerBasic() { return ( <Field> <FieldLabel>Reporting period</FieldLabel> <DateRangePicker endName="periodEnd" startName="periodStart" /> <FieldDescription>Type both dates or choose them from the calendar.</FieldDescription> </Field> );}Installation
The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.
pnpm add @slotted/react @slotted/theme @slotted/themesimport { DateRangePicker, DateRangePickerDefaultsProvider } from '@slotted/react';Typing or choosing
Each end is its own date field: type the month, day and year of the start, and Tab moves on to the end. Or press the calendar button and choose two days. The first press in the calendar starts the range and the second closes it; the panel holds both as a draft until Apply. Between the two ends, the head of the panel shows the length the next press would make, and its two steps move the end one day. The value reports its reason: keyboard or blur for a typed end, select for a range applied from the panel, and clear for the clear button. A two-digit year resolves through yearPivot, as in the date field.
Type both dates, or choose two days in the calendar.
import { useState } from 'react';import type { DateRange } from '@slotted/react/calendar';import { DateRangePicker, type DateRangePickerValueReason } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { toISODate, type PlainDate } from '@slotted/core/date';const HOW: Record<DateRangePickerValueReason, string> = { blur: 'completed when the field lost focus', clear: 'cleared', keyboard: 'typed', pointer: 'pressed', programmatic: 'set from code', select: 'chosen in the calendar',};const iso = (date: PlainDate | null) => (date === null ? 'open' : toISODate(date));export default function DateRangePickerTyping() { const [period, setPeriod] = useState<DateRange | null>(null); const [last, setLast] = useState('Type both dates, or choose two days in the calendar.'); return ( <Field> <FieldLabel>Audit window</FieldLabel> <DateRangePicker onValueChange={(value, request) => { setPeriod(value); setLast( value === null ? `No dates, ${HOW[request.reason as DateRangePickerValueReason]}.` : `${iso(value.start)} to ${iso(value.end)}, ${HOW[request.reason as DateRangePickerValueReason]}.`, ); }} value={period} /> <FieldDescription>{last}</FieldDescription> </Field> );}Two months, or one
The panel shows two months side by side, because a range often crosses a month boundary. months sets another count. One month suits ranges that stay inside a month, such as a promotion. Under 760 pixels the panel shows one month.
Promotions run inside one month.
import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate } from '@slotted/core/date';export default function DateRangePickerMonths() { return ( <Field> <FieldLabel>Promotion window</FieldLabel> <DateRangePicker defaultValue={{ start: plainDate(2026, 10, 5), end: plainDate(2026, 10, 18) }} months={1} /> <FieldDescription>Promotions run inside one month.</FieldDescription> </Field> );}Sizes
size sets the frame, both fields and the calendar button to one step of the control scale: sm for toolbars and dense filter panels, md for most forms, lg for sparse forms. Inside a field, an unset size follows the field.
import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate } from '@slotted/core/date';export default function DateRangePickerSizes() { return ( <Stack gap={5}> <Field> <FieldLabel>Created between</FieldLabel> <DateRangePicker size="sm" defaultValue={{ start: plainDate(2026, 9, 1), end: plainDate(2026, 9, 30) }} /> </Field> <Field> <FieldLabel>Billing period</FieldLabel> <DateRangePicker size="md" defaultValue={{ start: plainDate(2026, 10, 1), end: plainDate(2026, 10, 31) }} /> </Field> <Field> <FieldLabel>Lease term</FieldLabel> <DateRangePicker size="lg" defaultValue={{ start: plainDate(2026, 11, 1), end: plainDate(2027, 10, 31) }} /> </Field> </Stack> );}Variants
outline is the default frame. subtle fills the control, for a form on a tinted surface. plain draws no frame at rest and still shows hover and focus. The two fields inside draw no frame of their own: the date range picker draws one frame for both and answers hover, focus and invalid once.
import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate } from '@slotted/core/date';const QUARTER = { start: plainDate(2026, 7, 1), end: plainDate(2026, 9, 30) };export default function DateRangePickerVariants() { return ( <Stack gap={5}> <Field> <FieldLabel>Outline</FieldLabel> <DateRangePicker variant="outline" defaultValue={QUARTER} /> </Field> <Field> <FieldLabel>Subtle</FieldLabel> <DateRangePicker variant="subtle" defaultValue={QUARTER} /> </Field> <Field> <FieldLabel>Plain</FieldLabel> <DateRangePicker variant="plain" defaultValue={QUARTER} /> </Field> </Stack> );}States
Set invalid, readOnly, disabled and required on the field, which passes them to the date range picker; each can also be set on the date range picker itself. An end before its start is invalid without your help: the date range picker marks the end field and the frame, and it does not swap the ends. Read-only keeps both dates legible and focusable. Read-only and disabled both disable the calendar button, so the calendar cannot open.
Error:The end date is before the start date.
Set by finance when the quarter opens.
Unlocks once the pricing review is approved.
import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldError, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate } from '@slotted/core/date';export default function DateRangePickerStates() { return ( <Stack gap={5}> <Field invalid required> <FieldLabel>Campaign dates</FieldLabel> <DateRangePicker defaultValue={{ start: plainDate(2026, 10, 12), end: plainDate(2026, 10, 5) }} /> <FieldError>The end date is before the start date.</FieldError> </Field> <Field readOnly> <FieldLabel>Fiscal quarter</FieldLabel> <DateRangePicker defaultValue={{ start: plainDate(2026, 7, 1), end: plainDate(2026, 9, 30) }} /> <FieldDescription>Set by finance when the quarter opens.</FieldDescription> </Field> <Field disabled> <FieldLabel>Price freeze</FieldLabel> <DateRangePicker defaultValue={{ start: plainDate(2026, 11, 23), end: plainDate(2026, 12, 31) }} /> <FieldDescription>Unlocks once the pricing review is approved.</FieldDescription> </Field> </Stack> );}Earliest and latest dates
min and max bound both fields and the calendar. The calendar disables the days outside the bounds, and a date typed outside them marks the date range picker invalid and stays in the field. Once both ends are set, each field is also bounded by the other: the start cannot step past the end, and the end cannot step before the start.
Carriers accept bookings from October 1 to December 31, 2026.
import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate } from '@slotted/core/date';export default function DateRangePickerBounds() { return ( <Field> <FieldLabel>Shipment window</FieldLabel> <DateRangePicker max={plainDate(2026, 12, 31)} min={plainDate(2026, 10, 1)} /> <FieldDescription> Carriers accept bookings from October 1 to December 31, 2026. </FieldDescription> </Field> );}Days or nights
count decides what the length counts. days counts both ends, for a leave request or a rental. nights counts the nights between them, for a hotel stay. The same two dates give 5 days or 4 nights, and the same day at both ends is 1 day or 0 nights. The head of the panel and the calendar button’s accessible name both say the length in that unit.
Counted in nights: October 12 to 16 is 4 nights.
Counted in days: October 12 to 16 is 5 days.
import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate } from '@slotted/core/date';const TRIP = { start: plainDate(2026, 10, 12), end: plainDate(2026, 10, 16) };export default function DateRangePickerCount() { return ( <Stack gap={5}> <Field> <FieldLabel>Hotel stay</FieldLabel> <DateRangePicker count="nights" defaultValue={TRIP} /> <FieldDescription>Counted in nights: October 12 to 16 is 4 nights.</FieldDescription> </Field> <Field> <FieldLabel>Trade show leave</FieldLabel> <DateRangePicker count="days" defaultValue={TRIP} /> <FieldDescription>Counted in days: October 12 to 16 is 5 days.</FieldDescription> </Field> </Stack> );}Shortest and longest range
minLength and maxLength limit the length, counted in the unit count names. Once a start is chosen, the calendar disables the days that would make the range too short or too long, and the footer names the rule, such as “2 to 14 days”. A typed range outside the limits marks the date range picker invalid; the footer says by how much, the days past the limit are marked, and Apply is disabled.
Rentals run from 2 to 14 days.
import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';export default function DateRangePickerLimits() { return ( <Field> <FieldLabel>Forklift rental</FieldLabel> <DateRangePicker maxLength={14} minLength={2} /> <FieldDescription>Rentals run from 2 to 14 days.</FieldDescription> </Field> );}Unavailable dates
isDateUnavailable receives each date and returns true for a date the reader cannot choose. The calendar disables those days. A range must not run across an unavailable day: once a start is chosen, the calendar also disables every day beyond the first unavailable day on either side. A typed range that contains an unavailable day marks the date range picker invalid. Describe the rule in the field’s description, so the reader knows why a day is refused.
import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { compareDate, plainDate, type PlainDate } from '@slotted/core/date';const BOOKED_FROM = plainDate(2026, 10, 14);const BOOKED_TO = plainDate(2026, 10, 16);const isBooked = (date: PlainDate) => compareDate(date, BOOKED_FROM) >= 0 && compareDate(date, BOOKED_TO) <= 0;export default function DateRangePickerUnavailable() { return ( <Field> <FieldLabel>Training room</FieldLabel> <DateRangePicker isDateUnavailable={isBooked} /> <FieldDescription> Booked October 14 to 16. A booking cannot run across those days. </FieldDescription> </Field> );}Ranges across unavailable dates
contiguous={false} lets a range run across unavailable days and checks only its two ends. Use it when the rule is about the days a range starts and ends on, such as a vacation that has to start and end on a working day and may include a weekend.
import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { dayOfWeek, toISODate, type PlainDate } from '@slotted/core/date';const HOLIDAYS = new Set(['2026-10-12', '2026-11-11', '2026-11-26', '2026-12-25']);const isNonWorkingDay = (date: PlainDate) => dayOfWeek(date) === 0 || dayOfWeek(date) === 6 || HOLIDAYS.has(toISODate(date));export default function DateRangePickerAcrossUnavailable() { return ( <Field> <FieldLabel>Vacation</FieldLabel> <DateRangePicker contiguous={false} isDateUnavailable={isNonWorkingDay} /> <FieldDescription> Start and end on a working day. Weekends and holidays inside the vacation are fine. </FieldDescription> </Field> );}Shortcuts
presets adds a column of shortcuts beside the calendar. Each one is a label and the range it writes, or a function that returns the range when the panel draws it, for a relative shortcut such as the last 7 days. The panel writes the two dates under the label. Pressing one puts its range in the draft, and Apply writes it. A shortcut that breaks a rule of the date range picker is disabled. The date range picker ships no list of shortcuts: “Last 30 days” and “This quarter” depend on your product’s calendar.
import type { DateRange } from '@slotted/react/calendar';import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldLabel } from '@slotted/react/field';import { addDays, plainDate, type PickerPreset } from '@slotted/core/date';const TODAY = plainDate(2026, 9, 30);const LAST_30_DAYS: DateRange = { start: addDays(TODAY, -29), end: TODAY };const PRESETS: PickerPreset<DateRange>[] = [ { label: 'Last 7 days', value: { start: addDays(TODAY, -6), end: TODAY } }, { label: 'Last 30 days', value: LAST_30_DAYS }, { label: 'This quarter', value: { start: plainDate(2026, 7, 1), end: TODAY } }, { label: 'Last quarter', value: { start: plainDate(2026, 4, 1), end: plainDate(2026, 6, 30) } }, { label: 'Year to date', value: { start: plainDate(2026, 1, 1), end: TODAY } },];export default function DateRangePickerPresets() { return ( <Field> <FieldLabel>Report period</FieldLabel> <DateRangePicker defaultValue={LAST_30_DAYS} max={TODAY} presets={PRESETS} /> </Field> );}Locale and format
locale takes a BCP 47 tag and sets the order, separators and placeholders of both fields, the month and weekday names in the calendar, the dates in the head of the panel, and the dates the calendar button announces. There is no format string: each locale writes its own shape. Unset, the locale comes from SlottedProvider in React or provideSlotted in Angular, and falls back to en-US. The value stays the same pair of PlainDate objects in every locale.
import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate } from '@slotted/core/date';const SEASON = { start: plainDate(2026, 11, 2), end: plainDate(2026, 12, 23) };export default function DateRangePickerLocale() { return ( <Stack gap={5}> <Field> <FieldLabel>Peak season, United States (en-US)</FieldLabel> <DateRangePicker defaultValue={SEASON} locale="en-US" /> </Field> <Field> <FieldLabel>Peak season, United Kingdom (en-GB)</FieldLabel> <DateRangePicker defaultValue={SEASON} locale="en-GB" /> </Field> <Field> <FieldLabel>Peak season, Germany (de-DE)</FieldLabel> <DateRangePicker defaultValue={SEASON} locale="de-DE" /> </Field> </Stack> );}First day of the week and week numbers
The calendar starts the week on the day the locale uses. firstDayOfWeek overrides it with a number from 0, Sunday, to 6, Saturday. weekNumbers adds a column of ISO 8601 week numbers, and a press on a number chooses its week; ISO weeks start on Monday, so set firstDayOfWeek to 1 to keep each row inside one numbered week.
Sprints run two ISO weeks, Monday to Friday.
import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate } from '@slotted/core/date';export default function DateRangePickerFirstDay() { return ( <Field> <FieldLabel>Sprint 42</FieldLabel> <DateRangePicker defaultValue={{ start: plainDate(2026, 10, 5), end: plainDate(2026, 10, 16) }} firstDayOfWeek={1} weekNumbers /> <FieldDescription>Sprints run two ISO weeks, Monday to Friday.</FieldDescription> </Field> );}Controlled
Pass value and update it from onValueChange in React, or bind [value] and update it from (valueChange) in Angular, when other parts of the screen depend on the range. The value is a DateRange, { start, end }, where each end is a PlainDate or null; a range with both ends empty is null. Buttons outside the date range picker can set the value, and both fields and the calendar follow.
Statement from 2026-09-01 to 2026-09-30.
import { useState } from 'react';import { Button } from '@slotted/react/button';import type { DateRange } from '@slotted/react/calendar';import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';import { endOfMonth, plainDate, startOfMonth, stepMonth, toISODate } from '@slotted/core/date';const SEPTEMBER: DateRange = { start: plainDate(2026, 9, 1), end: plainDate(2026, 9, 30) };const FALLBACK = plainDate(2026, 9, 1);/** The calendar month before or after the one the range starts in. */const shift = (range: DateRange | null, months: number): DateRange => { const first = startOfMonth(stepMonth(range?.start ?? FALLBACK, months).date); return { start: first, end: endOfMonth(first) };};export default function DateRangePickerControlled() { const [period, setPeriod] = useState<DateRange | null>(SEPTEMBER); return ( <Stack gap={4}> <Field> <FieldLabel>Statement period</FieldLabel> <DateRangePicker onValueChange={(value) => setPeriod(value)} value={period} /> <FieldDescription> {period?.start && period.end ? `Statement from ${toISODate(period.start)} to ${toISODate(period.end)}.` : 'Choose both dates to run the statement.'} </FieldDescription> </Field> <Inline gap={2}> <Button size="sm" tone="secondary" variant="outline" onClick={() => setPeriod(shift(period, -1))} > Previous month </Button> <Button size="sm" tone="secondary" variant="outline" onClick={() => setPeriod(shift(period, 1))} > Next month </Button> <Button size="sm" tone="secondary" variant="ghost" onClick={() => setPeriod(null)}> Clear </Button> </Inline> </Stack> );}Clearing
clearable adds one clear button to the frame while either end holds a date, and Clear to the footer of the panel. It empties both ends with the reason clear and moves focus to the start field. With required, neither is drawn. The two fields do not draw clear buttons of their own.
Clear the dates to list orders from any date.
import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate } from '@slotted/core/date';export default function DateRangePickerClearable() { return ( <Field> <FieldLabel>Order date</FieldLabel> <DateRangePicker clearable defaultValue={{ start: plainDate(2026, 9, 14), end: plainDate(2026, 9, 27) }} /> <FieldDescription>Clear the dates to list orders from any date.</FieldDescription> </Field> );}An open end
A range with one end, such as { start, end: null }, is a value: the field shows the start and leaves the end empty, where the reader sees it. Use it for a period with no end yet, such as a price that stays valid until further notice. Open the panel on the end, and the first press writes the missing day.
Leave the end empty for a price with no end date.
import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate } from '@slotted/core/date';export default function DateRangePickerOpenEnd() { return ( <Field> <FieldLabel>Price valid</FieldLabel> <DateRangePicker clearable defaultValue={{ start: plainDate(2026, 10, 1), end: null }} /> <FieldDescription>Leave the end empty for a price with no end date.</FieldDescription> </Field> );}Editing one end
The end being edited carries data-current in the frame and is marked in the head of the panel, and the calendar opens on that end’s day. Focusing a field, or pressing an end in the head, makes it the current one. defaultPosition="end" starts on the end, so the first press in the calendar writes the end and keeps the start, which suits extending a booking. position and onPositionChange in React, or [position] and (positionChange) in Angular, control it.
Returns 2026-10-09. Open the calendar and press a day to move the return date.
import { useState } from 'react';import type { DateRange } from '@slotted/react/calendar';import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate, toISODate } from '@slotted/core/date';export default function DateRangePickerPosition() { const [rental, setRental] = useState<DateRange | null>({ start: plainDate(2026, 10, 5), end: plainDate(2026, 10, 9), }); return ( <Field> <FieldLabel>Scissor lift rental</FieldLabel> <DateRangePicker defaultPosition="end" onValueChange={(value) => setRental(value)} value={rental} /> <FieldDescription> {rental?.end ? `Returns ${toISODate(rental.end)}. Open the calendar and press a day to move the return date.` : 'Choose a return date.'} </FieldDescription> </Field> );}Confirmation and footer
The panel holds a draft: Apply writes it, Clear empties it when the picker is clearable, and Escape or a press outside leaves the value as it was. confirm={false} in React, or confirm="false" in Angular, drops Apply, and the press that closes the range writes it and closes the panel. footer in React and an element with slDateRangePickerFooter in Angular set the text beside the actions; unset, it names the limits.
import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate } from '@slotted/core/date';export default function DateRangePickerFooter() { return ( <Field> <FieldLabel>Stock count freeze</FieldLabel> <DateRangePicker confirm={false} defaultValue={{ start: plainDate(2026, 10, 30), end: plainDate(2026, 11, 1) }} footer="No shipments leave on these days" /> <FieldDescription>The second press sets the freeze.</FieldDescription> </Field> );}In a form
In React, startName and endName add two hidden inputs that submit the ends as ISO strings, such as 2026-10-14, whether they were typed or chosen. In Angular, the date range picker is a form control: formControlName, formControl and ngModel bind the whole DateRange, and the date range picker reports slottedDateRangeOrder for an end before its start, slottedDateRangeMin and slottedDateRangeMax for a date outside the bounds, slottedDateRangeUnavailable for an unavailable date and slottedDateRangeLength for a length outside the limits. Validators.required accepts a range with one open end, so this example checks for both ends with its own validator. Submit without dates to see the required error, type an end before the start to see the order error, then reset.
import { useState } from 'react';import type { SubmitEvent } from 'react';import { Button } from '@slotted/react/button';import type { DateRange } from '@slotted/react/calendar';import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldError, FieldLabel } from '@slotted/react/field';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';import { compareDate } from '@slotted/core/date';const problem = (range: DateRange | null, submitted: boolean) => { if (range?.start && range.end && compareDate(range.end, range.start) < 0) { return 'The end date must be on or after the start date.'; } if (submitted && (range?.start == null || range.end == null)) { return 'Enter a start and an end date.'; } return '';};export default function DateRangePickerForm() { const [range, setRange] = useState<DateRange | null>(null); const [submitted, setSubmitted] = useState(false); const [saved, setSaved] = useState<string | null>(null); const error = problem(range, submitted); const submit = (event: SubmitEvent<HTMLFormElement>) => { event.preventDefault(); setSubmitted(true); const data = new FormData(event.currentTarget); setSaved( problem(range, true) === '' ? `Freeze saved from ${String(data.get('freezeStart'))} to ${String(data.get('freezeEnd'))}.` : null, ); }; const reset = () => { setRange(null); setSubmitted(false); setSaved(null); }; return ( <form noValidate onSubmit={submit} onReset={reset}> <Stack gap={5}> <Field required invalid={error === '' ? undefined : true}> <FieldLabel>Code freeze</FieldLabel> <DateRangePicker endName="freezeEnd" onValueChange={(value) => setRange(value)} startName="freezeStart" value={range} /> <FieldError live="polite" reserve> {error} </FieldError> </Field> <Inline gap={3} align="center"> <Button type="submit">Save freeze</Button> <Button type="reset" tone="secondary" variant="outline"> Reset </Button> {saved && ( <Text size="sm" tone="muted"> {saved} </Text> )} </Inline> </Stack> </form> );}Narrow screens
Under 760 pixels, the panel shows one month and the shortcuts become a strip. Under 480 pixels on a touch screen, it opens as a sheet attached to the bottom of the viewport instead of a popover under the frame. The positioner carries data-presentation="sheet".
import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldLabel } from '@slotted/react/field';import { addDays, plainDate } from '@slotted/core/date';const TODAY = plainDate(2026, 9, 30);export default function DateRangePickerNarrow() { return ( <Field> <FieldLabel>Deliveries between</FieldLabel> <DateRangePicker max={TODAY} presets={[ { label: 'Today', value: { start: TODAY, end: TODAY } }, { label: 'Last 7 days', value: { start: addDays(TODAY, -6), end: TODAY } }, ]} /> </Field> );}Keyboard and the trigger’s name
Alt+ArrowDown opens the calendar from either field and leaves focus in the field, so typing continues. Enter or Space on the calendar button opens it and moves focus to the day of the current end, or to today when that end is empty. Tab and Shift+Tab cycle through the shortcuts, the calendar and the footer until the panel closes. The arrow keys move between days, and the head of the panel says the length of the range the focused day would make; Enter or Space on a day starts the range and, pressed again, completes it. Ctrl+Enter applies. Escape closes the panel, discards the draft, and returns focus to the calendar button; while the calendar shows the month or year grid, Escape first returns to the day grid. The calendar button’s accessible name carries both dates and the length, so a screen reader announces them when focus returns. messages replaces that name: choose while no range is set, and change with its {start}, {end} and {length} slots once one is. onOpenChange in React and (openChange) in Angular report why the calendar opened or closed.
Focus either date and press Alt+ArrowDown.
import { useState } from 'react';import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate } from '@slotted/core/date';const MESSAGES = { choose: 'Choose blackout dates', change: 'Change blackout dates, {start} to {end}, {length}',};export default function DateRangePickerKeyboard() { const [last, setLast] = useState('Focus either date and press Alt+ArrowDown.'); return ( <Field> <FieldLabel>Shipping blackout</FieldLabel> <DateRangePicker defaultValue={{ start: plainDate(2026, 11, 26), end: plainDate(2026, 11, 29) }} messages={MESSAGES} onOpenChange={(open, request) => setLast(`${open ? 'Opened' : 'Closed'} by ${request.reason}.`) } /> <FieldDescription>{last}</FieldDescription> </Field> );}Focus and open from code
The date range picker’s handle has focus(), which puts focus on the first segment of the current end, or of the end you pass: focus('end'). It also has open() and close() in React, named openSurface() and closeSurface() in Angular. Opening from code moves focus into the calendar, as the calendar button does. Reach the handle with ref in React and #picker="slDateRangePicker" in Angular.
import { useRef } from 'react';import { Button } from '@slotted/react/button';import { DateRangePicker, type DateRangePickerHandle } from '@slotted/react/date-range-picker';import { Field, FieldLabel } from '@slotted/react/field';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';import { plainDate } from '@slotted/core/date';export default function DateRangePickerFocusAndOpen() { const picker = useRef<DateRangePickerHandle>(null); return ( <Stack gap={4}> <Field> <FieldLabel>Contract term</FieldLabel> <DateRangePicker ref={picker} defaultValue={{ start: plainDate(2026, 4, 1), end: plainDate(2027, 3, 31) }} /> </Field> <Inline gap={2}> <Button size="sm" tone="secondary" variant="outline" onClick={() => picker.current?.focus('end')} > Edit end date </Button> <Button size="sm" tone="secondary" variant="outline" onClick={() => picker.current?.open()}> Open calendar </Button> </Inline> </Stack> );}Defaults for a section
DateRangePickerDefaultsProvider in React and provideDateRangePickerDefaults in Angular set count, months, variant, size, placement, confirm, timeZone, today and calendar once for every date range picker under them, such as a travel booking form. A value set on one date range picker still wins, and inside a field the field’s size wins over the provider’s.
import { DateRangePicker, DateRangePickerDefaultsProvider } from '@slotted/react/date-range-picker';import { Field, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate } from '@slotted/core/date';export default function DateRangePickerDefaults() { return ( <DateRangePickerDefaultsProvider count="nights" months={1} variant="subtle"> <Stack gap={4}> <Field> <FieldLabel>Lisbon hotel</FieldLabel> <DateRangePicker defaultValue={{ start: plainDate(2026, 11, 9), end: plainDate(2026, 11, 12) }} /> </Field> <Field> <FieldLabel>Porto hotel</FieldLabel> <DateRangePicker defaultValue={{ start: plainDate(2026, 11, 12), end: plainDate(2026, 11, 14) }} /> </Field> </Stack> </DateRangePickerDefaultsProvider> );}Reporting period filter for a dashboard
A dashboard filter in the small size, with the shortcuts analysts use most and max at today. The figures recompute from the chosen range, and the comparison uses the period of the same length that ends the day before it starts.
from 1,558 previous 7 days
over 7 days
import { useState } from 'react';import type { DateRange } from '@slotted/react/calendar';import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldLabel } from '@slotted/react/field';import { Grid } from '@slotted/react/grid';import { Stack } from '@slotted/react/stack';import { StatCard, StatCardComparison, StatCardDelta, StatCardFigure, StatCardHeader, StatCardLabel, StatCardPeriod, StatCardValue,} from '@slotted/react/stat-card';import { addDays, daysBetween, plainDate, type PickerPreset, type PlainDate,} from '@slotted/core/date';const TODAY = plainDate(2026, 9, 30);const LAST_7_DAYS: DateRange = { start: addDays(TODAY, -6), end: TODAY };const PRESETS: PickerPreset<DateRange>[] = [ { label: 'Last 7 days', value: LAST_7_DAYS }, { label: 'Last 30 days', value: { start: addDays(TODAY, -29), end: TODAY } }, { label: 'This quarter', value: { start: plainDate(2026, 7, 1), end: TODAY } },];/** Orders shipped on one day, from the Northwind warehouse feed. */const ordersOn = (date: PlainDate) => 150 + date.month * 6 + ((date.day * 37) % 50);const ordersBetween = (start: PlainDate, end: PlainDate) => { let total = 0; for (let date = start; daysBetween(date, end) >= 0; date = addDays(date, 1)) { total += ordersOn(date); } return total;};export default function DateRangePickerReportingFilter() { const [period, setPeriod] = useState<DateRange | null>(LAST_7_DAYS); const whole = period?.start && period.end ? { start: period.start, end: period.end } : null; const days = whole ? daysBetween(whole.start, whole.end) + 1 : 0; const orders = whole ? ordersBetween(whole.start, whole.end) : 0; const previous = whole ? ordersBetween(addDays(whole.start, -days), addDays(whole.start, -1)) : 0; const delta = previous === 0 ? 0 : (orders - previous) / previous; return ( <Stack gap={5}> <Field size="sm"> <FieldLabel>Period</FieldLabel> <DateRangePicker max={TODAY} onValueChange={(value) => setPeriod(value)} presets={PRESETS} value={period} /> </Field> <Grid gap={4} minItemWidth="sm"> <StatCard delta={delta} goodWhen="up"> <StatCardHeader> <StatCardLabel>Orders shipped</StatCardLabel> </StatCardHeader> <StatCardFigure> <StatCardValue value={orders} /> <StatCardDelta /> <StatCardComparison> from {previous.toLocaleString('en-US')}{' '} <StatCardPeriod>previous {days} days</StatCardPeriod> </StatCardComparison> </StatCardFigure> </StatCard> <StatCard> <StatCardHeader> <StatCardLabel>Orders per day</StatCardLabel> </StatCardHeader> <StatCardFigure> <StatCardValue value={days === 0 ? 0 : Math.round(orders / days)} /> <StatCardComparison> over <StatCardPeriod>{days} days</StatCardPeriod> </StatCardComparison> </StatCardFigure> </StatCard> </Grid> </Stack> );}Booking a warehouse dock window
A carrier books dock 4 for one to three weekdays. Weekends and the days another carrier holds are unavailable, so once a start is chosen the calendar stops at the next held day; maxLength stops it at three days, and min and max keep the booking inside the open schedule.
Book 1 to 3 weekdays from October 1. Booked as of Wednesday, September 30, 2026: Oct 7–8 and Oct 21–23.
import { useState } from 'react';import type { DateRange } from '@slotted/react/calendar';import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { createDateFormat, dayOfWeek, plainDate, toISODate, type PlainDate,} from '@slotted/core/date';const TODAY = plainDate(2026, 9, 30);/** Days another carrier already holds dock 4. */const HELD = new Set(['2026-10-07', '2026-10-08', '2026-10-21', '2026-10-22', '2026-10-23']);const words = createDateFormat({ locale: 'en-US' });const isClosed = (date: PlainDate) => dayOfWeek(date) === 0 || dayOfWeek(date) === 6 || HELD.has(toISODate(date));export default function DateRangePickerDockBooking() { const [slot, setSlot] = useState<DateRange | null>(null); return ( <Field required> <FieldLabel>Dock 4 unloading window</FieldLabel> <DateRangePicker isDateUnavailable={isClosed} max={plainDate(2026, 11, 30)} maxLength={3} min={plainDate(2026, 10, 1)} onValueChange={(value) => setSlot(value)} value={slot} /> <FieldDescription> {slot?.start && slot.end ? `Dock 4 is yours from ${words.describe(slot.start)} to ${words.describe(slot.end)}.` : `Book 1 to 3 weekdays from October 1. Booked as of ${words.describe(TODAY)}: Oct 7–8 and Oct 21–23.`} </FieldDescription> </Field> );}Comparing two periods
The date range picker holds one range. To compare two periods, use two of them: the second one’s shortcuts are computed from the first, so “Previous period” and “Same period last year” always match the period being analyzed.
Shortcuts follow the period above.
import { useState } from 'react';import type { DateRange } from '@slotted/react/calendar';import { DateRangePicker } from '@slotted/react/date-range-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { addDays, daysBetween, plainDate, stepYear, type PickerPreset } from '@slotted/core/date';const SEPTEMBER: DateRange = { start: plainDate(2026, 9, 1), end: plainDate(2026, 9, 30) };/** The run of the same length that ends the day before the period starts. */const previousPeriod = (period: DateRange): DateRange | null => { if (period.start === null || period.end === null) return null; const days = daysBetween(period.start, period.end) + 1; return { start: addDays(period.start, -days), end: addDays(period.start, -1) };};const lastYear = (period: DateRange): DateRange | null => period.start === null || period.end === null ? null : { start: stepYear(period.start, -1).date, end: stepYear(period.end, -1).date };/** The two baselines of a period, as shortcuts. */const shortcutsOf = (period: DateRange | null): PickerPreset<DateRange>[] => { const previous = period && previousPeriod(period); const sameLastYear = period && lastYear(period); return [ ...(previous ? [{ label: 'Previous period', value: previous }] : []), ...(sameLastYear ? [{ label: 'Same period last year', value: sameLastYear }] : []), ];};export default function DateRangePickerComparePeriods() { const [period, setPeriod] = useState<DateRange | null>(SEPTEMBER); const [baseline, setBaseline] = useState<DateRange | null>(previousPeriod(SEPTEMBER)); return ( <Stack gap={5}> <Field> <FieldLabel>Period</FieldLabel> <DateRangePicker onValueChange={(value) => setPeriod(value)} value={period} /> </Field> <Field> <FieldLabel>Compare to</FieldLabel> <DateRangePicker onValueChange={(value) => setBaseline(value)} presets={shortcutsOf(period)} value={baseline} /> <FieldDescription>Shortcuts follow the period above.</FieldDescription> </Field> </Stack> );}Accessibility
| Key | Effect | Focus |
|---|---|---|
| Alt+ArrowDown | open | stays in the field |
| Enter, Space | open | the cell of the current end, or today when it is empty |
| Escape | close | trigger |
| Tab | contained | — |
- The trigger says aria-haspopup="dialog" and its name carries the value written, which is where focus returns when the panel closes.
- The panel is a dialog with its Tab wrapped, and each grid inside it is one stop.
- Escape discards the draft and returns focus to the trigger. Ctrl+Enter applies from anywhere in the panel.
- The footer’s hint is a status region, so the reason Apply is off is spoken as well as drawn.
- Alt+ArrowDown opens the panel and leaves focus in the field, so the segments keep every key they had.
- The length between the two halves is a status region, so a reader hears "4 nights" on every arrow as much as they see it on every hover.
- The half being edited is a tint and a line, so it is told without color.
API
DateRangePicker
Props
valueDateRange | null- The run held, either end of which may be null. Present means the consumer owns it.
defaultValueDateRange | nullDefaultnull- What it starts from, and returns to on a form reset. Read once.
position'start' | 'end'- The end the next press writes. Present means the consumer owns it.
defaultPosition'start' | 'end'Defaultstart- The end it starts on.
count'days' | 'nights'Defaultdays- What the length counts.
minLengthnumber- The shortest run, in the unit count names.
maxLengthnumber- The longest run, in the unit count names.
contiguousbooleanDefaulttrue- Whether a run may cross an unavailable day.
minPlainDate- The earliest accepted date.
maxPlainDate- The latest accepted date.
isDateUnavailable(date: PlainDate) => boolean- Refuses particular dates.
presetsreadonly PickerPreset<DateRange>[]- The consumer’s own shortcuts.
confirmbooleanDefaulttrue- Whether the panel keeps a draft until Apply.
monthsnumberDefault2- How many months the panel shows. One below 760 pixels.
weekNumbersbooleanDefaultfalse- Draws the ISO week number, as a press that chooses the week.
fixedWeeksbooleanDefaultfalse- Six rows whatever the months need.
firstDayOfWeeknumberDefault the locale’s- 0 is Sunday.
yearPivotnumber- How a two-digit typed year resolves.
calendar'gregory'Defaultgregory- The calendar system.
startNamestring- The name a form posts the start under.
endNamestring- The name a form posts the end under.
invalidboolean- Stated by the consumer; a run that fails a rule is invalid without it.
openboolean- Whether the panel is showing. Present means the consumer owns it.
defaultOpenbooleanDefaultfalse- Whether it starts open when nobody else says. Read once.
placement'bottom-start' | 'bottom' | 'bottom-end' | 'top-start' | 'top' | 'top-end'Defaultbottom-start- Where the panel opens, before the positioner has read the room.
size'sm' | 'md' | 'lg'Defaultmd- The height of the control. The field around it answers when the picker does not.
variant'outline' | 'subtle' | 'plain'Defaultoutline- How the control draws its frame.
localestringDefault the language in force- BCP 47. Writes the field, the panel and the trigger’s name.
timeZonestringDefault the runtime’s- Which zone answers "what is now".
todayPlainDateDefault the clock’s- The day it is: the mark of today, and the month an empty panel opens on.
disabledboolean- Answers no key and no press.
readOnlyboolean- Readable and not changeable.
requiredboolean- The form needs a value.
clearablebooleanDefaultfalse- Draws a clear on the control and in the panel, unless required.
messagesPartial<DateRangePickerMessages>- Words laid over the language in force: the trigger’s names, the two ends, what is said of a refused run, and the phrases that count it.
Events
| Name | Payload | When |
|---|---|---|
onValueChange | (value: DateRange | null, request: ChangeRequest<DateRange | null>) | Before the value moves, and cancellable: from a key in a field, from Apply, from Clear. |
onOpenChange | (open: boolean, request: ChangeRequest<boolean>) | Before the panel opens or closes, with the reason. |
onPositionChange | (position: DateRangePickerPosition, request: ChangeRequest<DateRangePickerPosition>) | Before the end being edited moves. |
Composition
DateRangePickerDefaultsProvidercomponent- On applicationSets calendar, confirm, count, months, placement, size, timeZone, today and variant once.
footerReactNodeDefault the limits- What the footer says when nothing is wrong.
render(props: DateRangePickerRootProps) => ReactNode- Substitutes the element the root renders.
refRef<DateRangePickerHandle>- focus(), open() and close().
Parts
| Part | Element | Required | Purpose |
|---|---|---|---|
root | div, or the element render returns | Yes | The frame of the picker. Carries data-ui="date-range-picker", data-count, data-size, data-variant, data-open and the state attributes. |
control | div | Yes | The box the panel hangs from, around the field and the trigger. |
trigger | button | Yes | The button that opens the panel. Its name carries both ends and the length written. |
start | div | Yes | The wrapper of the field of the start, with data-current while it is the end being edited. |
separator | span | Yes | The dash between the two fields. |
end | div | Yes | The wrapper of the field of the end, on the same terms. |
clear | button | No | Empties both ends, with clearable and a value. |
Theming
Each token is a CSS custom property: set it in a theme, or on any element to retune every date range picker inside it.
Date Range Picker tokens
| Token | Default |
|---|---|
--slotted-date-range-picker-action-active-background | var(--slotted-tone-secondary-subtle-active) |
--slotted-date-range-picker-action-color | var(--slotted-text-muted, GrayText) |
--slotted-date-range-picker-action-hover-background | var(--slotted-tone-secondary-subtle-hover) |
--slotted-date-range-picker-action-size | min( calc(var(--_icon-size) + 2 * var(--slotted-space-2, 0.25rem)), calc(var(--_height) - var(--_border-width) * 2 - var(--slotted-space-2, 0.25rem)) ) |
--slotted-date-range-picker-background | var(--slotted-control-surface, Field) |
--slotted-date-range-picker-border-color | var(--slotted-control-border-color, ButtonBorder) |
--slotted-date-range-picker-color | var(--slotted-text, CanvasText) |
--slotted-date-range-picker-current-color | var(--slotted-tone-accent-solid) |
--slotted-date-range-picker-current-size | 2px |
--slotted-date-range-picker-disabled-background | var(--slotted-disabled-background) |
--slotted-date-range-picker-disabled-border-color | var(--slotted-disabled-border) |
--slotted-date-range-picker-disabled-color | var(--slotted-disabled-foreground) |
--slotted-date-range-picker-hover-border-color | var(--slotted-tone-accent-border) |
--slotted-date-range-picker-invalid-border-color | var(--slotted-tone-danger-border) |
--slotted-date-range-picker-invalid-edge-width | var(--slotted-control-invalid-edge-width, 1px) |
--slotted-date-range-picker-invalid-focus-ring-color | var(--slotted-focus-ring-color-invalid, Highlight) |
--slotted-date-range-picker-plain-hover-background | var(--slotted-tone-secondary-subtle-hover) |
--slotted-date-range-picker-radius | var(--slotted-control-radius, 4px) |
--slotted-date-range-picker-readonly-background | var(--slotted-tone-secondary-subtle-hover) |
--slotted-date-range-picker-separator-color | var(--slotted-text-muted, GrayText) |
--slotted-date-range-picker-shadow | var(--slotted-control-shadow, none) |
--slotted-date-range-picker-subtle-background | var(--slotted-surface-sunken, Canvas) |
--slotted-date-range-picker-subtle-border-color | var(--slotted-border-subtle, ButtonBorder) |
--slotted-date-range-picker-subtle-hover-background | var(--slotted-tone-secondary-subtle-hover) |
Theme tokens it reads
| Token | Default |
|---|---|
--slotted-border-subtle | Set per scheme by the theme |
--slotted-control-border-color | Set per scheme by the theme |
--slotted-control-border-width | var(--slotted-border-width-thin) |
--slotted-control-font-family | var(--slotted-font-family-sans) |
--slotted-control-font-size-lg | comfortable 14px · compact 13px · dense 12px |
--slotted-control-font-size-md | comfortable 13px · compact 12px · dense 12px |
--slotted-control-font-size-sm | comfortable 12px · compact 12px · dense 12px |
--slotted-control-gap-lg | comfortable 8px · compact 6px · dense 6px |
--slotted-control-gap-md | comfortable 8px · compact 6px · dense 4px |
--slotted-control-gap-sm | comfortable 6px · compact 4px · dense 4px |
--slotted-control-height-lg | comfortable 38px · compact 32px · dense 30px |
--slotted-control-height-md | comfortable 34px · compact 28px · dense 26px |
--slotted-control-height-sm | comfortable 30px · compact 26px · dense 24px |
--slotted-control-icon-size-lg | comfortable 18px · compact 16px · dense 14px |
--slotted-control-icon-size-md | comfortable 16px · compact 14px · dense 13px |
--slotted-control-icon-size-sm | comfortable 14px · compact 13px · dense 12px |
--slotted-control-invalid-edge-width | var(--slotted-border-width-thin) |
--slotted-control-padding-inline-lg | comfortable 16px · compact 12px · dense 10px |
--slotted-control-padding-inline-md | comfortable 13px · compact 10px · dense 8px |
--slotted-control-padding-inline-sm | comfortable 10px · compact 8px · dense 6px |
--slotted-control-radius | var(--slotted-radius-sm) |
--slotted-control-shadow | Set per scheme by the theme |
--slotted-control-shadow-focus-geometry | 0 1px 4px -1px |
--slotted-control-surface | Set per scheme by the theme |
--slotted-control-transition-duration | var(--slotted-duration-short) |
--slotted-control-transition-easing | var(--slotted-easing-standard) |
--slotted-disabled-background | Set per scheme by the theme |
--slotted-disabled-border | Set per scheme by the theme |
--slotted-disabled-foreground | Set per scheme by the theme |
--slotted-focus-ring-color | Set per scheme by the theme |
--slotted-focus-ring-color-invalid | Set per scheme by the theme |
--slotted-focus-ring-offset | var(--slotted-border-width-thick) |
--slotted-focus-ring-width | var(--slotted-border-width-thick) |
--slotted-radius-none | 0px |
--slotted-radius-xs | 2px |
--slotted-space-1 | 0.125rem |
--slotted-space-2 | 0.25rem |
--slotted-surface-sunken | Set per scheme by the theme |
--slotted-target-comfortable | 44px |
--slotted-target-min | 24px |
--slotted-text | Set per scheme by the theme |
--slotted-text-muted | Set per scheme by the theme |
--slotted-tone-accent-border | Set per scheme by the theme |
--slotted-tone-accent-solid | Set per scheme by the theme |
--slotted-tone-danger-border | Set per scheme by the theme |
--slotted-tone-secondary-subtle-active | Set per scheme by the theme |
--slotted-tone-secondary-subtle-hover | Set per scheme by the theme |