Skip to content

Forms

IDateRangePicker ​

A two-month calendar for picking a span — a reporting period, a filter window, a stay. The model is a pair of ISO YYYY-MM-DD strings, like IDatePicker.

Both ends are null while nothing is chosen, and the first click sets start with end still null. Guard on period.end before querying with the range.

Presets ​

presets puts shortcuts beside the calendar. Picking one fills the range and closes the picker. commonDateRangePresets() builds the usual set: today, yesterday, the last 7 and 30 days, this month and last month, all relative to today in the viewer's time zone.

The preset matching the current range is highlighted, and any preset that falls outside min or max is disabled. Pass labels to translate the built-in set, or write your own presets. A function range is re-run every time the picker opens, so relative presets never go stale.

ts
const presets = [
  ...commonDateRangePresets({ today: 'Danes', yesterday: 'Včeraj' }),
  { label: 'Q3 2026', range: { start: '2026-07-01', end: '2026-09-30' } },
]

Months shown ​

Two months side by side is the default, since most ranges cross a month boundary. Drop to one where the popover has no room, or go to three for long ranges.

On screens narrower than Tailwind's sm breakpoint (40rem), the picker shows one month whatever months says, since two side by side won't fit a phone.

Bounds ​

Formatting and separator ​

format takes Intl.DateTimeFormatOptions and applies to both ends; separator is the text between them.

Locale and week start ​

clearLabel, previousLabel and nextLabel are props as well.

Clearable ​

Clearing sets both ends back to null.

Sizes ​

Invalid ​

Props ​

PropTypeDefaultDescription
size'sm' | 'md' | 'lg''md'Control scale
placeholderstring'Pick a date range'Shown while nothing is selected
disabledboolean—Trigger cannot be opened
invalidboolean—Red border and ring; inherited from IFormField when unset
idstring—Id for the trigger; IFormField supplies one
minstring—Earliest selectable date, ISO YYYY-MM-DD
maxstring—Latest selectable date, ISO YYYY-MM-DD
localestring—Month names, weekday initials and trigger text
formatIntl.DateTimeFormatOptions—How each end reads on the trigger
weekStartsOn0–6—0 is Sunday. Defaults to the locale's convention
monthsnumber2Months shown side by side; always one on narrow screens
presetsDateRangePreset[]—Shortcuts beside the calendar
presetsLabelstring'Presets'Accessible name for the preset list
clearableboolean—Adds a clear action to the footer
separatorstring' – 'Text between the two dates on the trigger
clearLabelstring'Clear'Clear action label
previousLabelstring'Previous month'Accessible name for the back arrow
nextLabelstring'Next month'Accessible name for the forward arrow
unstyledboolean—Drop built-in classes
classstring—Applied to the trigger, which carries the field chrome
ui{ trigger?, placeholder?, content?, panel?, presets?, preset?, header?, heading?, nav?, months?, grid?, headCell?, cell?, cellTrigger?, footer?, action? }—Per-element class overrides

Model ​

ts
interface DateRange {
  start: string | null
  end: string | null
}

The popover closes once both ends are set.