DateRangePicker

A composable date range picker that pairs two segmented date inputs — start and end — with a popover hosting a range calendar. The committed value is a { start, end } pair of YYYY-MM-DD strings, or null while the range is empty or incomplete.

ddmmyyyy
ddmmyyyy

Anatomy

DateRangePicker.Root owns the range value and open state. Two DateRangePicker.Input parts — one with part="start", one with part="end" — render locale-resolved segments, and DateRangePicker.Popover hosts a calendar fixed to range selection built from the same parts as the standalone Calendar.

<script>
	import { DateRangePicker } from '@human-kit/ui/daterangepicker';
</script>

<DateRangePicker.Root>
	<DateRangePicker.Input part="start" aria-label="Start date">
		{#snippet children(segment)}
			<DateRangePicker.Segment part="start" {segment} />
		{/snippet}
	</DateRangePicker.Input>
	<DateRangePicker.Input part="end" aria-label="End date">
		{#snippet children(segment)}
			<DateRangePicker.Segment part="end" {segment} />
		{/snippet}
	</DateRangePicker.Input>
	<DateRangePicker.Trigger />

	<DateRangePicker.Popover>
		<DateRangePicker.Calendar>
			<div>
				<DateRangePicker.TriggerPrevious />
				<DateRangePicker.Heading />
				<DateRangePicker.TriggerNext />
			</div>
			<DateRangePicker.Grid>
				<DateRangePicker.GridHeader />
				<DateRangePicker.GridBody />
			</DateRangePicker.Grid>
		</DateRangePicker.Calendar>
	</DateRangePicker.Popover>
</DateRangePicker.Root>

Min and max bounds

minValue and maxValue constrain both the calendar and the typed inputs. When the children snippet is omitted, DateRangePicker.Input renders its segments with default styling, as this demo shows.

ddmmyyyy
ddmmyyyy

Selectable range: 2026-05-01 → 2026-09-30 — value: null

Usage guidelines

  • Use value with onChange for controlled state and defaultValue for uncontrolled state; the value is a { start, end } pair and the empty state is null.
  • Always render one input with part="start" and one with part="end", and pass the same part to their segments.
  • Use open / defaultOpen / onOpenChange to control the popover, and closeOnSelect to keep it open after the range is confirmed.
  • isDateUnavailable marks specific days as non-selectable in both the inputs and the calendar.
  • Set visibleMonths on DateRangePicker.Calendar to show more than one month, which makes range selection easier.
  • Wrap in a LocaleProvider to localize segment order, placeholders, and calendar labels.

Accessibility

  • Give each input its own accessible name (for example aria-label="Start date" and aria-label="End date").
  • Segment accessible names are resolved automatically from the active locale.
  • Each input exposes aria-invalid and data-invalid when its segment draft is not committable; invalid input is shown, never auto-corrected.
  • Disabled calendar dates remain focusable via keyboard navigation so screen readers can discover and announce them as disabled.
  • In the range calendar, the first selection starts the range, arrow keys extend the preview, and Enter or Space confirms it.

API reference

Root

The stateful container. Owns the committed { start, end } range value, the popover open state, and validation shared by both inputs and the calendar.

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

Data attribute Description
data-disabled Present when the range picker is disabled.
data-focus-visible Present while focus should be visibly indicated (keyboard modality).
data-focus-within Present while any part of the range picker contains focus.
data-invalid Present while a segment draft is not committable.
data-open Present while the calendar popover is open.
data-readonly Present when the range picker is readonly.

Input

One segmented date input for one end of the range. Render one with part="start" and one with part="end"; segments render with default styling when the children snippet is omitted.

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

Data attribute Description
data-date-range-picker-input Identifies a range picker input element.
data-disabled Present when the range picker is disabled.
data-focus-visible Present while focus should be visibly indicated (keyboard modality).
data-focus-within Present while a segment inside the input has focus.
data-invalid Present while this input's segment draft is not committable.
data-open Present while the calendar popover is open.
data-readonly Present when the range picker is readonly.

Segment

One editable or literal segment of a range end (day, month, year, or separator). Supports typing and arrow-key stepping.

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

Data attribute Description
data-date-range-picker-segment Identifies a range picker segment element.
data-focus-visible Present while focus should be visibly indicated (keyboard modality).
data-focused Present while the segment has focus.
data-placeholder Present while the segment shows its placeholder instead of a value.
data-range-part Which end of the range the segment belongs to: 'start' or 'end'.
data-type The segment type, e.g. 'day', 'month', 'year', or 'literal'.

Trigger

Button that opens and closes the range calendar popover.

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

Data attribute Description
data-focus-visible Present while focus should be visibly indicated (keyboard modality).
data-focused Present while the trigger has focus.

Popover

The floating panel that hosts the range calendar. Forwards Popover.Content props (placement, offset, shouldFlip, …); open state, trigger wiring, and id are controlled internally.

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

Calendar

The calendar surface inside the popover, fixed to range selection. Forwards Calendar.Root props such as visibleMonths, except those controlled by DateRangePicker.Root.

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

TriggerPrevious

Button that pages the calendar to the previous month (or set of visible months).

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

Heading

Displays the visible month heading, localized through the active locale.

TriggerNext

Button that pages the calendar to the next month (or set of visible months).

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

Grid

Renders one visible month as an accessible grid named after the month heading.

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

Data attribute Description
data-calendar-grid Identifies the grid element.
data-calendar-month The ISO month (YYYY-MM) rendered by this grid.

GridHeader

The weekday header row. Iterates the localized weekday labels and passes each to the children snippet.

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

HeaderCell

One weekday label cell inside the grid header row.

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

GridBody

The day cells area. Iterates the visible days and passes each ISO date to the children snippet.

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

Data attribute Description
data-week Identifies a week row inside the grid body.

BodyCell

One focusable day cell. The first selection starts the range, hover previews it, and the second selection confirms it.

Prop Type Default

* required. Native HTML attributes of the underlying element are also accepted.

Data attribute Description
data-date The ISO YYYY-MM-DD date of the cell.
data-disabled Present when the day cannot be selected (disabled, out of range, or unavailable).
data-focus-visible Present while focus should be visibly indicated (keyboard modality).
data-focused Present while the cell has focus.
data-hovered Present while the pointer is over the cell.
data-in-range Present when the day falls inside the selected or previewed range.
data-outside-month Present when the day belongs to an adjacent month.
data-pressed Present while the cell is actively pressed.
data-range-end Present on the last day of the selected or previewed range.
data-range-start Present on the first day of the selected or previewed range.
data-selected Present when the day is part of the committed range.
data-today Present on today's date.
data-unavailable Present when isDateUnavailable marks the day as unavailable.