DatePicker

A composable date picker that pairs a segmented date input with a calendar popover for selecting YYYY-MM-DD dates.

ddmmyyyy

Value: null

Anatomy

DatePicker.Root owns the value and open state. DatePicker.Input renders locale-resolved segments, DatePicker.Trigger opens the popover, and DatePicker.Popover hosts a full calendar built from the same parts as the standalone Calendar.

<script>
	import { DatePicker } from '@human-kit/ui/datepicker';
</script>

<DatePicker.Root>
	<DatePicker.Input aria-label="Date input">
		{#snippet children(segment)}
			<DatePicker.Segment {segment} />
		{/snippet}
	</DatePicker.Input>
	<DatePicker.Trigger />

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

Min and max bounds

minValue and maxValue constrain both the calendar and typed input. Out-of-range dates are never auto-corrected: the input exposes aria-invalid and data-invalid while the committed value stays null, so users can see exactly what they typed.

ddmmyyyy

Selectable range: 2026-02-10 → 2026-02-20

Usage guidelines

  • Use value with onChange for controlled state and defaultValue for uncontrolled state; the empty state is null.
  • Use open / defaultOpen / onOpenChange to control the popover, and closeOnSelect to keep it open after selection.
  • isDateUnavailable marks specific days as non-selectable in both the input and the calendar.
  • DatePicker.Popover forwards Popover.Content props such as placement (default bottom-start), offset, and shouldFlip.
  • DatePicker.Calendar forwards Calendar.Root props except those controlled by the root (value, selectionMode, disabled, …).
  • Wrap in a LocaleProvider to localize segment order, placeholders, and calendar labels.

Accessibility

  • Segment accessible names are resolved automatically from the active locale.
  • DatePicker.Input exposes aria-invalid and data-invalid when the current 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.
  • Popover focus defaults to the current active day cell; closing with the keyboard restores visible focus to the trigger.
  • In read-only mode, the calendar trigger is hidden.

API reference

Root

The stateful container. Owns the committed date value, the popover open state, and validation shared by the input and calendar.

Prop Type Default

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

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

Input

The segmented date input. Iterates the locale-resolved segments and passes each to the children snippet.

Prop Type Default

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

Data attribute Description
data-disabled Present when the date 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 the current segment draft is not committable.
data-open Present while the calendar popover is open.
data-readonly Present when the date picker is readonly.

Segment

One editable or literal segment of the date (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-picker-segment Identifies a date 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-type The segment type, e.g. 'day', 'month', 'year', or 'literal'.

Trigger

Button that opens and closes the calendar popover. Hidden in read-only mode.

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 calendar. Forwards Popover.Content props (placement, offset, shouldFlip, …); open state, trigger wiring, and id are controlled internally. Placement defaults to bottom-start and initial focus lands on the active day cell.

Prop Type Default

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

Calendar

The calendar surface inside the popover. Forwards Calendar.Root props except those controlled by DatePicker.Root (selectionMode, value, disabled, readonly, isDateUnavailable, …).

Prop Type Default

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

TriggerPrevious

Button that pages the calendar to the previous month.

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.

Prop Type Default

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

Grid

Renders the 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. Selecting it commits the date to the picker and (by default) closes the popover.

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 a selected range (range calendars).
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 a selected range (range calendars).
data-range-start Present on the first day of a selected range (range calendars).
data-selected Present when the day is the committed value.
data-today Present on today's date.
data-unavailable Present when isDateUnavailable marks the day as unavailable.