Skip to content
GitHub (opens in a new tab)

DateTimePicker

Pick a calendar date and a time in one field.

stableMoleculecontracts/datetimepicker.json

Preview

DateTimePicker

One field for a day and a time. The dialog has the shared header with Close, and keeps the month grid and the time together until Done, Close or Escape.

Master

A day only is DatePicker. A time only is TimePicker. A range of days is DateRangePicker.

Usage

value is a date in YYYY-MM-DD and a time in HH:mm. Done closes the dialog. Escape does too, and returns focus to the field.

Do's

  • An appointment, deadline, or schedule that needs both a day and a time

Don'ts

<Field label="Starts" htmlFor="starts">
  <DateTimePicker id="starts" value={value} onValueChange={setValue} />
</Field>

When to use

  • An appointment, deadline, or schedule that needs both a day and a time

When not to use

  • A date only — use DatePicker
  • A time only — use TimePicker
  • A range of dates — use DateRangePicker

What an agent reads

import { DateTimePicker } from "agentic-ds-kit";
must
  • Escape closes only this panel, not a parent Modal, Drawer or AlertDialog
  • Trigger is a button with aria-haspopup=dialog, aria-expanded, and aria-controls
  • The dialog (aria-modal) has the shared overlay header (CalendarDays icon, the picked date and time or the placeholder as the eyebrow, the Choose date and time title, Close), then the month grid and a TimePicker
  • Opening focuses the picked day (else today). Tab stays inside the dialog
  • Choosing a day or a time updates the value and leaves the dialog open until Done or Escape
  • Escape, Close and Done close and return focus to the trigger
  • Must have a Field label pointing at id
  • built-in labels (previousMonth, nextMonth, chooseDateAndTime, time, close) come from KitLabelsProvider; English by default
defaults
  • size md
  • hourCycle 12
  • disabled false
  • error false
  • placeholder Pick a date and time
stops if
  • Do not use two fields when one DateTimePicker is the control
  • Do not invent a local calendar or a native datetime-local input
  • Do not use raw hex

From contracts/datetimepicker.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
idstringYes——
sizemd | sm | lgNomdTrigger height sm 32, md 36, lg 40, like Input. The TimePicker in the panel is sm when size is sm, else md.
value{ date?: string, time?: string }No—date is YYYY-MM-DD. time is HH:mm.
defaultValue{ date?: string, time?: string }No——
onValueChangefunctionNo—(value: { date?, time? }) => void
hourCycle12 | 24No12—
disabledbooleanNofalse—
errorbooleanNofalse—
minDatestringNo—YYYY-MM-DD. Earlier days are struck through and unavailable.
maxDatestringNo—YYYY-MM-DD. Later days are struck through and unavailable.
namestringNo—Hidden input submits date and time as YYYY-MM-DDTHH:mm.
describedBystringNo——
placeholderstringNoPick a date and time—
  • Component
    →

    DatePicker

    Form field that opens a month grid to pick one date.

  • Component
    →

    TimePicker

    Pick a time of day as hour and minute, in 12-hour or 24-hour form.

  • Component
    →

    DateRangePicker

    Pick a date range from named presets such as This month or Last 30 days, from two months side by side, or by typing the start and end, then Apply.