Components

Date Picker

A date field with a calendar popup. Type a date or pick one, alone or as a range.

Usage

import {
  DatePicker,
  DatePickerContent,
  DatePickerField,
  DatePickerInput,
  DatePickerTrigger,
} from 'nyctoui/date-picker'

<DatePicker defaultValue="2026-12-14">
  <DatePickerField>
    <DatePickerInput aria-label="Due date" />
    <DatePickerTrigger />
  </DatePickerField>
  <DatePickerContent />
</DatePicker>

The input reads dates in the locale’s order, ISO dates and month names, and formats the date once it is committed with Enter or on blur. Text that isn’t a date marks the field invalid and keeps the last good value. Either way the value is an ISO date string.

The popup is a Calendar: it takes the same options on the root, such as min, unavailable and minDays, and the same parts inside DatePickerContent. Without children it shows the navigation and the months.

Good for

  • A due date on a task in a project tool.
  • Check-in and check-out on a hotel or rental booking form.
  • A report’s date range in an analytics dashboard, with presets like Last 7 days.
  • An appointment date in a clinic’s booking flow.

Anatomy

<DatePicker>
  <DatePickerField>
    <DatePickerInput />
    <DatePickerInput end />
    <DatePickerClear />
    <DatePickerTrigger />
  </DatePickerField>
  <DatePickerHint />
  <DatePickerContent>
    <DatePickerPresets>
      <DatePickerPreset />
    </DatePickerPresets>
    <DatePickerCalendar>
      <CalendarNav />
      <CalendarMonths />
      <CalendarFooter />
    </DatePickerCalendar>
  </DatePickerContent>
</DatePicker>

Examples

Range

mode="range" takes an input for each end; the second has end. The popup stays open after the start and closes once the end is picked.

Booking

A stay of at least 3 nights with nightly prices, around booked nights, in two large months. DatePickerClear shows once there are dates to clear.

Presets

DatePickerPreset picks its value and closes the popup, and shows as selected while it matches. The app works out relative dates such as the last 7 days.

Hint and clear

The hint is read with the input. Its children function gets an example date in the locale’s format.

Button trigger

Where typing isn’t needed, put a Calendar in a Popover behind a button. Control open to close it once a date is picked.

Best practices

Do
  • Let people type the date as well as pick it; typing is faster when they already know it.
  • Set min, max and unavailable to the dates that make sense, so wrong ones can’t be chosen.
  • Add DatePickerPresets for ranges people pick again and again, such as Last 30 days or This quarter.
  • Add DatePickerClear when the date is optional.
Don’t
  • Use a range picker when only one date is needed.
  • Use a date picker for text that isn’t a calendar date, like a card’s expiry month.
  • Hide the label unless the context makes the date’s purpose obvious.

API reference

DatePicker

Holds the value and the open state, and takes every Calendar option. Renders a <div>.

PropTypeDefault
mode
One date, or a range with an input for each end.
'single' | 'range''single'
value / defaultValue
The selected date or range.
string | [string, string] | null—
onValueChange
Called when a date is picked, typed and committed, cleared or set by a preset.
(value, details) => void—
calendarSize
Day size in the popup, as Calendar’s size.
'md' | 'lg''md'
months
How many months the popup shows side by side.
number1
min / max / unavailable
Dates that can’t be picked. They are invalid when typed too.
string / DateMatchers—
minDays / maxDays / allowUnavailable
Range limits, as on Calendar.
number / boolean—
open / defaultOpen / onOpenChange
The popup’s open state.
boolean—
closeOnSelect
Closes the popup once a date or a range’s end is picked.
booleantrue
name / startName / endName
Form field names. The value submits as ISO dates.
string—
required / disabled / readOnly
As on a native input.
booleanfalse
controller
Drives it from elsewhere. Create one with createDatePickerController().
DatePickerController—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

DatePickerField

The input box around the inputs and buttons; the popup lines up under it. Renders a <div>.

PropTypeDefault
size
Control height; matches Input and Button.
'sm' | 'md' | 'lg''md'
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

DatePickerInput

Where a date is typed. Renders an <input>.

PropTypeDefault
end
Holds a range’s end.
booleanfalse
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

DatePickerTrigger

A ghost icon button that opens the popup, named by the chosen date. Renders a <button>.

PropTypeDefault
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

DatePickerClear

Clears the value and focuses the input; hidden while empty. Renders a <button>.

PropTypeDefault
aria-label
The accessible name of the button.
string'Clear date'
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

DatePickerHint

Describes the expected format. Renders a <span>.

PropTypeDefault
children
The state has example, a date in the locale’s format.
ReactNode | (state) => ReactNode—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

DatePickerContent

The popup. Renders a <div> in the top layer.

PropTypeDefault
side
Which side of the field to open on. Flips when it would clip.
'top' | 'right' | 'bottom' | 'left''bottom'
align
How to line up with the field.
'start' | 'center' | 'end''start'
anchor
Positions against another element than the field.
Element | string | null—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

DatePickerCalendar

Lays out the Calendar parts beside presets. Renders a <div>.

PropTypeDefault
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

DatePickerPresets

A column of presets beside the calendar. Renders a <div> with the group role.

PropTypeDefault
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

DatePickerPreset

Picks its value and closes the popup. Renders a <button>.

PropTypeDefault
value
The date or range it picks.
string | [string, string]—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—