Date and time picker

Slant / Forms

A date and a time of day in one field, with limits and the time zone shown.

Demo

Usage

@tuttn/slant
import { DateTimePicker, Field } from '@tuttn/slant'

// In a Field, uncontrolled: the label names the group, and a name submits
// "2026-11-03T09:00" (the datetime-local format).
<Field>
  <Field.Label>Publish on</Field.Label>
  <DateTimePicker defaultValue={new Date(2026, 10, 3, 9, 0)} min={new Date()} name="publishAt" />
</Field>

// Controlled: the value is a local Date to the minute, or null until the
// date and the time are both set.
const [publishAt, setPublishAt] = useState<Date | null>(null)
<DateTimePicker value={publishAt} onValueChange={setPublishAt} label="Publish on" />

// Limits: the calendar stops at the days of min and max, and on those days
// the time is checked too. A moment outside them is still reported, marks the
// field invalid and says so under it.
<DateTimePicker min={opensAt} max={closesAt} minuteStep={15} label="Interview" />

// The line under the field: the reader's zone by default, your own text, or none.
<DateTimePicker timeZone="Times are in UTC." label="Maintenance window" />
<DateTimePicker timeZone={false} label="Reminder" />

Props

PropTypeDefaultDescription
valueDate | null—The date and time, as a local Date with hours and minutes (seconds zero), or null while either part is missing. Pass it to control the field; leave it out to let the field keep its own.
defaultValueDate | nullnullThe date and time an uncontrolled field starts with.
onValueChange(value: Date | null) => void—Called with the combined Date once the date and the time are both set, and with null when either is cleared. A time outside `min` and `max` is still reported.
minDate—The earliest moment that can be chosen. The calendar stops at its day, and on that day the time is checked against its hours and minutes.
maxDate—The latest moment that can be chosen. The calendar stops at its day, and on that day the time is checked against its hours and minutes.
isDateDisabled(date: Date) => boolean—Called with a local midnight; dates it returns true for can't be chosen, typed or picked.
localestringthe document's lang, else 'en'The locale both parts read and write in: the date's numeric order, the calendar's names, the time's segments and clock.
hourCycle12 | 24the locale'sA 12-hour clock (hours 1 to 12 and a day period) or a 24-hour one.
minuteStepnumber—How many minutes the time's arrow keys step by.
weekStartsOn0 | 10 where the locale's week starts on Sunday, else 1The calendar's first weekday: 1 for Monday, 0 for Sunday.
todayDatenowThe day the calendar marks as today, and the example date in the date's placeholder and format hint.
timeZoneReactNode | falsemessages.timeZone(the reader's IANA zone), read after mount: "Time zone: Europe/London"The line under the field. `false` hides it.
dateLabelstringmessages.dateThe date input's accessible name (and its calendar's).
timeLabelstringmessages.timeThe time's accessible name.
labelstring—The group's accessible name, unless a Field's label or `aria-labelledby` names it.
namestring—Submits the moment with a form: a hidden input holding `2026-11-03T09:00` (the `datetime-local` format), or `''` while the date or the time is missing.
formstring—The id of the form the hidden input belongs to, when the field sits outside it.
size'sm' | 'md' | 'lg''md'Height of both parts on the control scale: 28, 34 or 40px at regular density.
invalidboolean—Marks both parts invalid. Inside a Field, the field's `invalid` does this; a moment outside `min` and `max` does too.
disabledboolean—Disables both parts. A disabled field submits nothing.
readOnlyboolean—Keeps both parts focusable and readable, but neither changes.
requiredboolean—Marks both parts required.
…restHTMLAttributes<HTMLDivElement>—className, style, other attributes and the ref reach the root: the role="group" element around both parts and the lines under them.

Keyboard

Tab / Shift+TabMoves through the date input, the calendar button and each of the time’s segments, in that order.
Enter (date)Commits the typed date, and still submits a form around the field when it is one.
Alt+ArrowDown (date)Opens the calendar on the chosen day, else today.
Arrows, Page Up / Page Down (calendar)Move by day, week and month.
Enter / Space (calendar)Picks the focused day, closes the calendar and returns focus to its button.
Escape (calendar)Closes the calendar without picking.
0–9 (time)Types into the focused segment, moving on once no further digit could fit.
ArrowUp / ArrowDown (time)Steps the segment (minutes by minuteStep) and wraps.
Home / End (time)Sets the segment to its lowest or highest.
ArrowLeft / ArrowRight (time)Moves between the segments in the order they sit on screen.
A / P (day period)Sets the morning or the afternoon on a 12-hour clock.
Backspace / Delete (time)Clears the segment; the value becomes null while the date stays.

Accessibility

  • The root is a role="group" named by a Field’s label through aria-labelledby, else by label, and described by the field’s description and error, the time-zone line and, while the moment is outside the range, the range error.
  • The date input is named dateLabel (messages.date, "Date") and the time’s group timeLabel (messages.time, "Time"), so a reader hears "Publish on, group, Date".
  • Invalid, required, read-only and disabled reach both parts, which carry them as their own pages describe; a moment outside min and max marks both invalid.
  • When a change takes the moment outside the range, messages.dateTimeOutOfRange is announced politely once, and stays as the error line under the field.

Value

The field is made of a Date picker and a Time field. The value is a local Date to the minute (seconds zero): onValueChange is called with it once the date and the time are both set, and with null when either is cleared. Each part keeps what was entered while the other is missing, so a parent that re-renders with null leaves a half-filled field as it was. A controlled value sets both parts, and null clears both when it replaces a whole value. A time the day doesn't have (inside a daylight-saving gap) becomes the one the browser gives for it, and the time part shows that.

Limits

min and max are moments. The calendar stops at their days and dims the days beyond, and a typed date past them is refused, as in the Date picker. On the day of min the time is checked against its hours and minutes (to the minute, so min={new Date()} allows the current one), and likewise on the day of max. A moment outside the range is still reported, but marks the field invalid and shows messages.dateTimeOutOfRange under it. isDateDisabled rules out days, as in the Date picker.

Time zone

The value is in the reader’s own time zone, so by default the line under the field names it: messages.timeZone with the browser’s IANA zone, "Time zone: Europe/London". It is read after mount, so a server render can’t disagree with the browser, and the line keeps its height until then. Pass timeZone to write your own line, or false to hide it.

Forms

With a name, a hidden input submits the moment in the datetime-local format, 2026-11-03T09:00, or an empty string while the date or the time is missing; a disabled field submits nothing. The parts themselves have no names. Enter in the date input commits the date before a form around the field submits, so the form carries the new moment.

Layout

The parts sit side by side and wrap under each other when the group is narrow; both take size. Under <Slant dir="rtl"> the date sits at the inline start, on the right, and the time keeps its own left-to-right order.