View as Markdown

DateRangePicker

DateRangePicker

Two date fields with a separator, a popup with presets, two months side by side, the range summary and Apply / Cancel; minDays, maxDays, bounds and range form values.

import { DateRangePicker, getRangeDays } from '@salmonui/calendars/date-range-picker';
import '@salmonui/calendars/date-range-picker/styles.css';

<DateRangePicker
  label="Stay"
  minDays={2}
  maxDays={14}
  presets={[{ label: 'Next 7 days', value: () => ({ start: today(), end: addDays(today(), 6) }) }]}
  onValueChange={(range) => setRange(range)}
/>;

Value

value / defaultValue are DateRange objects ({ start, end }, each a date input) or null; onValueChange(range, details) receives { start: PlainDate, end: PlainDate } and details.iso, the ISO 8601 interval start/end. getRangeDays(range) returns the inclusive day count.

The popup

  • Two months side by side (visibleMonths, default 2); under a narrow container one month shows, by a CSS container query, without measuring.
  • The first click sets the start, hovering or focusing previews the range (data-in-range, data-range-end on the day cells), the second click sets the end and fires onRangeSelect(range). The summary shows the range and its day count with the localeText.selectedDays plural forms.
  • confirm (default true) commits on Apply; Cancel restores. confirm={false} commits on the second click.
  • presets: { label, value }[] render as a listbox; a value function is evaluated when the popup opens, so "last 7 days" never freezes at server render time. Choosing a preset commits and closes.
  • minDays / maxDays disable the days that would make the span too short or too long once a start is chosen.
  • isDateDisabled, renderDay and getDayProps work as in DatePicker; rangeOverDisabled: 'block' | 'allow' (default 'block') decides whether a range may span disabled days; with 'block' the days past the next disabled day cannot end the range.
  • Alt+Right / Alt+Left move between the presets, the calendars and the buttons (mirrored in RTL); Tab follows the same order.

Fields

The two DateFields sit in one labelled group with separator between them (a ReactNode, default an en dash). Paste on either field splits the text on the separator (or an en dash, /, -, to) and parses both ends. format applies to both fields. granularity="month" | "year" picks month or year ranges from the year or decade view. min, max and strict work as in DatePicker: with strict, an out-of-range end moves to the nearest bound on blur.

Range options and paste

Open demo

A custom separator that also splits pasted text, onRangeSelect before Apply, getRangeDays, a month range picker, strict quarter bounds and weekends and holidays that block or allow a range.

Sprint
11232026
12042026
Paste 2026-12-01 → 2026-12-11 into either field.
Working days off
12212026
12232026
Weekends and holidays are disabled.
Reporting months
012026
062026
Within Q1 2027 (strict)
02012027
02142027
Typed dates outside Q1 move to the nearest bound on blur.
  1. Choose or paste a range

Forms

name posts one ISO interval (2026-11-02/2026-11-06); startName and endName post two ISO dates instead.

API reference

The API reference for @salmonui/calendars/date-range-picker lists every prop, method and type. Open state, focus, forms and events shared by the pickers are in Picker behavior and forms; server rendering, accessibility coverage and budgets in SSR, accessibility and performance.

DateRangePicker

Open demo

Two months side by side, presets, a 2 to 14 day span, the day count and Apply / Cancel.

Stay
11092026
11132026
Quick range
mmddyyyy
mmddyyyy
2026-11-09 / 2026-11-13: 5 days