DatePicker

Text trigger over an anchored calendar — typed input commits, optional built-in time panel.

DatePicker is a text trigger opening an anchored Calendar popover: click or ArrowDown opens (ArrowDown dives straight into the grid), a day commits, Escape and outside clicks close and refocus, and typing a full date commits it too. With timepicker, a time panel rides along and values become YYYY-MM-DD HH:mm(:ss).

Installation

import { DatePicker } from "@iammikz/srui";

Usage

Props

PropTypeDefaultDescription
valuestring—YYYY-MM-DD, or with time when timepicker is on
defaultValuestring—Initial value
onChange(value: string) => void—Fires with the wire-format value
min / maxstring (YYYY-MM-DD)—Bounds; clip typing and the grid
timepickerbooleanfalseAttach the time panel
secondsbooleanfalseSeconds precision in the time panel
minuteStepnumber1Minute grid step
hour12booleantrue12-hour time display vs 24-hour
placeholderstring"Pick a date"Empty trigger text
ariaLabelstring"Date"Trigger label
disabled / invalidboolean—Usual field states
clearablebooleantrueTrailing clear button
format(value: string) => string—Custom trigger display
namestring—Renders a hidden input for native form posts

Examples

Date + time (timepicker)

The panel stays open after picking the day so the time can be refined; values carry HH:mm.

Accessibility

  • Combobox trigger semantics (aria-expanded/aria-haspopup) over a role="dialog" panel.
  • Escape closes and refocuses the input; clicking outside dismisses; the calendar keeps its grid keyboard map. ArrowDown opens the panel and moves focus onto the selected day, so the whole flow is keyboard-only.
  • With timepicker, the time columns are listboxes with arrow navigation.

Edge cases

  • timepicker={false} closes the panel after the day is picked; timepicker keeps it open for refinement.
  • Typed values outside min/max are clipped onto the boundary day.
  • Refining the time before picking a day is staged — the chosen time lands when the day is picked.

Upgrades over the PRUI original: a clear button, custom format, a name hidden input for form posts, and pre-day time staging.