Datetime Picker
A segmented date and time field with a calendar and a clock behind one trigger, for one moment that the reader can type or choose.
Type the date and time, or choose them from the calendar and the list.
import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';const FIRST_PICKUP = plainDateTime(plainDate(2026, 9, 30), plainTime(9, 0));export default function DateTimePickerBasic() { return ( <Field> <FieldLabel>Pickup date and time</FieldLabel> <DateTimePicker name="pickupAt" referenceDateTime={FIRST_PICKUP} /> <FieldDescription> Type the date and time, or choose them from the calendar and the list. </FieldDescription> </Field> );}Installation
The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.
pnpm add @slotted/react @slotted/theme @slotted/themesimport { DateTimePicker, DateTimePickerDefaultsProvider } from '@slotted/react';Typing or choosing
The field and the panel write the same value. Type the month, day, year, hour and minute into the segments, or press the calendar button, choose a day in the calendar and a time in the clock, and press Apply. The time can also be typed at the head of the clock. Each change reports its reason: keyboard for typing, select for a moment applied from the panel, clear for the clear button and blur for a value completed when the field loses focus. Press +, - or = on a segment to type a relative expression instead, such as +2h or +1d, measured from referenceDateTime.
No change yet.
import { useState } from 'react';import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate, plainDateTime, plainTime, toISODateTime } from '@slotted/core/date';const RECEIVED = plainDateTime(plainDate(2026, 9, 30), plainTime(14, 30));const REASONS: Record<string, string> = { keyboard: 'from the keyboard', select: 'chosen in the panel', clear: 'cleared', blur: 'completed when the field lost focus',};export default function DateTimePickerTyping() { const [change, setChange] = useState('No change yet.'); return ( <Field> <FieldLabel>Goods received at</FieldLabel> <DateTimePicker defaultValue={RECEIVED} onValueChange={(value, request) => { const text = value === null ? 'empty' : toISODateTime(value); setChange(`${text}, ${REASONS[request.reason] ?? request.reason}.`); }} referenceDateTime={RECEIVED} /> <FieldDescription>{change}</FieldDescription> </Field> );}Completing the value
The panel holds a draft: a day and a time are two presses, and Apply writes both and closes the panel. Apply stays disabled while a half is missing. A day pressed with no time moves focus to the clock. Escape and a press outside leave the value as it was. referenceDateTime states the moment it is: the month an empty panel opens on, the distance written over the clock, and what Now and the steps from now count from. Unset, it is the current time.
The panel opens on October 1 and counts its steps from 3:00 PM.
import { useState } from 'react';import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { createDateTimeFormat, plainDate, plainDateTime, plainTime, type PlainDateTime,} from '@slotted/core/date';const END_OF_SHIFT = plainDateTime(plainDate(2026, 10, 1), plainTime(15, 0));const words = createDateTimeFormat({ locale: 'en-US' });export default function DateTimePickerReference() { const [collection, setCollection] = useState<PlainDateTime | null>(null); return ( <Field> <FieldLabel>Courier collection</FieldLabel> <DateTimePicker onValueChange={setCollection} referenceDateTime={END_OF_SHIFT} value={collection} /> <FieldDescription> {collection === null ? 'The panel opens on October 1 and counts its steps from 3:00 PM.' : `Collection on ${words.describe(collection)}.`} </FieldDescription> </Field> );}12-hour and 24-hour clocks
hourCycle takes 12 or 24 and applies to the field, the clock and the date and time in words. Unset, the locale decides: en-US writes 12-hour times with AM and PM, en-GB and de-DE write 24-hour times.
import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';const DEPARTURE = plainDateTime(plainDate(2026, 9, 30), plainTime(18, 45));export default function DateTimePickerHourCycle() { return ( <Stack gap={5}> <Field> <FieldLabel>Departure, 12-hour clock</FieldLabel> <DateTimePicker defaultValue={DEPARTURE} hourCycle={12} /> </Field> <Field> <FieldLabel>Departure, 24-hour clock</FieldLabel> <DateTimePicker defaultValue={DEPARTURE} hourCycle={24} /> </Field> </Stack> );}Step between times
step sets the seconds between two times in the clock, 900 by default. The clock counts from the earliest time the day allows: the time of min on its own day, minTime on the other days, and midnight when neither is set. A step of 1800 from a minTime of 7:15 AM offers 7:15, 7:45 and 8:15. The step applies to the clock only: the field accepts any minute by typing and by the arrow keys.
Appointments start every 30 minutes from 7:15 AM.
import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';export default function DateTimePickerStep() { return ( <Field> <FieldLabel>Dock appointment</FieldLabel> <DateTimePicker maxTime={plainTime(16, 45)} minTime={plainTime(7, 15)} referenceDateTime={plainDateTime(plainDate(2026, 9, 30), plainTime(7, 15))} step={1800} /> <FieldDescription>Appointments start every 30 minutes from 7:15 AM.</FieldDescription> </Field> );}Hours, minutes or seconds
granularity sets how much of the time the field and the clock write: hour, minute (the default) or second. With second, the clock adds a grid of seconds under the minutes.
Shifts start on the hour.
The nightly run starts between 2:00:00 and 2:05:00 AM.
import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';export default function DateTimePickerGranularity() { return ( <Stack gap={5}> <Field> <FieldLabel>Shift starts</FieldLabel> <DateTimePicker defaultValue={plainDateTime(plainDate(2026, 10, 1), plainTime(6, 0))} granularity="hour" step={3600} /> <FieldDescription>Shifts start on the hour.</FieldDescription> </Field> <Field> <FieldLabel>Batch run starts</FieldLabel> <DateTimePicker defaultValue={plainDateTime(plainDate(2026, 9, 30), plainTime(2, 0, 30))} granularity="second" maxTime={plainTime(2, 5)} minTime={plainTime(2, 0)} step={30} /> <FieldDescription>The nightly run starts between 2:00:00 and 2:05:00 AM.</FieldDescription> </Field> </Stack> );}Stated times
options replaces the step with your own list of times, for a schedule that no step describes, such as departures or delivery windows. The clock draws whole times under the part of the day each one is in, in the order you give. The bounds and the predicates still refuse times in it, and there is no Now and no step from now.
The Chicago to Memphis trailer leaves five times a day.
import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';const DEPARTURES = [ plainTime(5, 40), plainTime(8, 15), plainTime(11, 50), plainTime(16, 5), plainTime(21, 30),];export default function DateTimePickerOptions() { return ( <Field> <FieldLabel>Line-haul departure</FieldLabel> <DateTimePicker options={DEPARTURES} referenceDateTime={plainDateTime(plainDate(2026, 9, 30), plainTime(8, 15))} /> <FieldDescription>The Chicago to Memphis trailer leaves five times a day.</FieldDescription> </Field> );}Earliest and latest
Two pairs of bounds apply together. min and max are whole date-times: where the range starts and where it ends. minTime and maxTime bound the times of every day inside the range. On the first day the clock starts at the time of min, on the last day it stops at the time of max, and the calendar disables the days outside the range. A value outside the bounds stays in the field and marks the datetime picker invalid.
From October 1 at 1:00 PM to October 9 at 12:00 PM, between 8:00 AM and 5:00 PM.
import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';export default function DateTimePickerBounds() { return ( <Field> <FieldLabel>Container collection</FieldLabel> <DateTimePicker defaultValue={plainDateTime(plainDate(2026, 10, 1), plainTime(13, 0))} max={plainDateTime(plainDate(2026, 10, 9), plainTime(12, 0))} maxTime={plainTime(17, 0)} min={plainDateTime(plainDate(2026, 10, 1), plainTime(13, 0))} minTime={plainTime(8, 0)} step={3600} /> <FieldDescription> From October 1 at 1:00 PM to October 9 at 12:00 PM, between 8:00 AM and 5:00 PM. </FieldDescription> </Field> );}Unavailable dates and times
isDateUnavailable receives each date and returns true for a day the reader cannot choose; the calendar disables it and its clock offers no time. isTimeUnavailable receives a time and the date it belongs to, so the rule can differ by day. The clock follows the day in the draft, and refused hours and minutes stay in place, disabled.
import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { dayOfWeek, plainDate, plainDateTime, plainTime, type PlainDate, type PlainTime,} from '@slotted/core/date';const isWeekend = (date: PlainDate) => dayOfWeek(date) === 0 || dayOfWeek(date) === 6;const isLunch = (time: PlainTime) => time.hour === 12;export default function DateTimePickerUnavailable() { return ( <Field> <FieldLabel>Warehouse inspection</FieldLabel> <DateTimePicker isDateUnavailable={isWeekend} isTimeUnavailable={isLunch} maxTime={plainTime(17, 0)} minTime={plainTime(8, 0)} referenceDateTime={plainDateTime(plainDate(2026, 9, 30), plainTime(9, 0))} step={1800} /> <FieldDescription> Weekdays from 8:00 AM to 5:00 PM, closed for lunch at noon. </FieldDescription> </Field> );}Time zones and wall-clock values
The value is a PlainDateTime: a date and a time with no time zone, the time a clock on the wall shows. toISODateTime writes it as 2026-09-30T14:00:00, the format of input[type=datetime-local], and parseISODateTime reads it back. When your server stores instants, wallClockIn from @slotted/core/date converts an instant to the wall-clock time in a time zone; converting back to an instant stays in your application. timeZone decides which day the calendar marks as today and what the Now shortcut writes. Stated, the zone is written over the clock. Unset, both come from the browser’s time zone. today states the day itself, such as a business date: Now keeps the time of the clock on that day.
Today and Now follow the clock in Chicago.
import { useState } from 'react';import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';import { toISODateTime, wallClockIn, type PlainDateTime } from '@slotted/core/date';/** The pickup as the server stores it: an instant, 7:00 PM UTC on September 30, 2026. */const STORED = Date.UTC(2026, 8, 30, 19, 0);export default function DateTimePickerTimeZones() { const [pickup, setPickup] = useState<PlainDateTime | null>( wallClockIn(STORED, 'America/Chicago'), ); return ( <Stack gap={4}> <Field> <FieldLabel>Pickup, Chicago terminal</FieldLabel> <DateTimePicker onValueChange={setPickup} timeZone="America/Chicago" value={pickup} /> <FieldDescription>Today and Now follow the clock in Chicago.</FieldDescription> </Field> <Text size="sm" tone="muted"> {pickup === null ? 'Value: null' : `Value: ${toISODateTime(pickup)}, with no offset`} </Text> </Stack> );}Locale and format
locale takes a BCP 47 tag and sets the order of the segments, their separators and placeholders, the clock, the month and weekday names in the calendar, and the date and time in words that the calendar button announces. There is no format string: each locale writes its own shape. Unset, the locale comes from SlottedProvider in React or provideSlotted in Angular, and falls back to en-US. The value is the same PlainDateTime in every locale.
import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';const PICKUP = plainDateTime(plainDate(2026, 9, 30), plainTime(14, 30));export default function DateTimePickerLocale() { return ( <Stack gap={5}> <Field> <FieldLabel>Pickup, United States (en-US)</FieldLabel> <DateTimePicker defaultValue={PICKUP} locale="en-US" /> </Field> <Field> <FieldLabel>Pickup, United Kingdom (en-GB)</FieldLabel> <DateTimePicker defaultValue={PICKUP} locale="en-GB" /> </Field> <Field> <FieldLabel>Pickup, Germany (de-DE)</FieldLabel> <DateTimePicker defaultValue={PICKUP} locale="de-DE" /> </Field> <Field> <FieldLabel>Pickup, Japan (ja-JP)</FieldLabel> <DateTimePicker defaultValue={PICKUP} locale="ja-JP" /> </Field> </Stack> );}Sizes
size sets the field and the trigger to one step of the control scale: sm for toolbars and filter rows, md for most forms, lg for sparse forms. Inside a field, an unset size follows the field.
import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';export default function DateTimePickerSizes() { return ( <Stack gap={5}> <Field> <FieldLabel>Created after</FieldLabel> <DateTimePicker defaultValue={plainDateTime(plainDate(2026, 9, 1), plainTime(0, 0))} size="sm" /> </Field> <Field> <FieldLabel>Pickup</FieldLabel> <DateTimePicker defaultValue={plainDateTime(plainDate(2026, 9, 30), plainTime(9, 0))} size="md" /> </Field> <Field> <FieldLabel>Store opening</FieldLabel> <DateTimePicker defaultValue={plainDateTime(plainDate(2026, 11, 2), plainTime(10, 0))} size="lg" /> </Field> </Stack> );}Variants
outline is the default frame. subtle fills the control, for a form on a tinted surface. plain draws no frame at rest, for a table cell or a toolbar, and still shows hover and focus.
import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';const PICKUP = plainDateTime(plainDate(2026, 9, 30), plainTime(9, 0));export default function DateTimePickerVariants() { return ( <Stack gap={5}> <Field> <FieldLabel>Pickup</FieldLabel> <DateTimePicker defaultValue={PICKUP} variant="outline" /> </Field> <Field> <FieldLabel>Loading starts</FieldLabel> <DateTimePicker defaultValue={PICKUP} variant="subtle" /> </Field> <Field> <FieldLabel>Gate opens</FieldLabel> <DateTimePicker defaultValue={PICKUP} variant="plain" /> </Field> </Stack> );}States
Set invalid, readOnly and disabled on the field, which passes them to the datetime picker; each can also be set on the datetime picker itself. Invalid draws the frame and the focus ring in the danger tone and sets aria-invalid. Read-only keeps the value legible and focusable. Read-only and disabled both disable the calendar button, so the panel cannot open.
Error:The pickup is before the order was placed, September 30 at 9:00 AM.
Set when the order was placed.
Filled in by the carrier on delivery.
import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldDescription, FieldError, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';export default function DateTimePickerStates() { return ( <Stack gap={5}> <Field invalid required> <FieldLabel>Pickup</FieldLabel> <DateTimePicker defaultValue={plainDateTime(plainDate(2026, 9, 29), plainTime(16, 0))} /> <FieldError>The pickup is before the order was placed, September 30 at 9:00 AM.</FieldError> </Field> <Field readOnly> <FieldLabel>Order placed</FieldLabel> <DateTimePicker defaultValue={plainDateTime(plainDate(2026, 9, 30), plainTime(9, 0))} /> <FieldDescription>Set when the order was placed.</FieldDescription> </Field> <Field disabled> <FieldLabel>Delivered</FieldLabel> <DateTimePicker /> <FieldDescription>Filled in by the carrier on delivery.</FieldDescription> </Field> </Stack> );}Controlled
Pass value and update it from onValueChange in React, or bind [value] and update it from (valueChange) in Angular, when other parts of the screen depend on the value. The handler receives a PlainDateTime, or null while the field is empty or holds only one half. Buttons outside the datetime picker can set the value; the field and the panel follow.
Call on October 1, 2026 at 9:00 AM.
import { useState } from 'react';import { Button } from '@slotted/react/button';import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';import { addDays, createDateTimeFormat, plainDate, plainDateTime, plainTime, type PlainDateTime,} from '@slotted/core/date';const TODAY = plainDate(2026, 9, 30);const words = createDateTimeFormat({ locale: 'en-US' });export default function DateTimePickerControlled() { const [call, setCall] = useState<PlainDateTime | null>( plainDateTime(addDays(TODAY, 1), plainTime(9, 0)), ); return ( <Stack gap={4}> <Field> <FieldLabel>Call Harbor Freightways</FieldLabel> <DateTimePicker onValueChange={setCall} value={call} /> <FieldDescription> {call === null ? 'No call scheduled.' : `Call on ${words.describe(call)}.`} </FieldDescription> </Field> <Inline gap={2}> <Button onClick={() => setCall(plainDateTime(addDays(TODAY, 1), plainTime(9, 0)))} size="sm" tone="secondary" variant="outline" > Tomorrow, 9:00 AM </Button> <Button onClick={() => setCall(plainDateTime(addDays(TODAY, 2), plainTime(14, 0)))} size="sm" tone="secondary" variant="outline" > Friday, 2:00 PM </Button> <Button onClick={() => setCall(null)} size="sm" tone="secondary" variant="ghost"> No call </Button> </Inline> </Stack> );}Clearing
clearable adds a clear button to the field while it holds any part of a value, and Clear to the footer of the panel. The button empties both halves, reports null with the reason clear and returns focus to the field. With required, neither is drawn.
Clear the date and time to release the shipment.
import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';export default function DateTimePickerClearable() { return ( <Field> <FieldLabel>Hold shipment until</FieldLabel> <DateTimePicker clearable defaultValue={plainDateTime(plainDate(2026, 10, 9), plainTime(17, 0))} /> <FieldDescription>Clear the date and time to release the shipment.</FieldDescription> </Field> );}Confirmation and footer
The panel keeps a draft until Apply, and Clear, with clearable, empties it. confirm={false} in React, or confirm="false" in Angular, drops Apply: each press on a whole moment writes it, and the press on the finest unit closes the panel. footer in React and an element with slDateTimePickerFooter in Angular set the text beside the actions; unset, it names the step.
import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';export default function DateTimePickerFooter() { return ( <Field> <FieldLabel>Maintenance window starts</FieldLabel> <DateTimePicker confirm={false} defaultValue={plainDateTime(plainDate(2026, 10, 3), plainTime(22, 0))} footer="Four hours from this time" step={3600} /> <FieldDescription>Conveyors stop for four hours from this time.</FieldDescription> </Field> );}In a form
name adds a hidden input that submits the value as an ISO string, such as 2026-10-01T08:00:00, whether it was typed or chosen. In Angular, the datetime picker is a form control: formControlName, formControl and ngModel bind the value, Validators.required applies to it, and the datetime picker reports slottedDateTimeRange outside min and max, slottedDateTimeWindow outside minTime and maxTime, slottedDateTimeUnavailable for a refused date or time and slottedDateTimeIncomplete while only one half is typed. In React, the value stays in your state and you validate it on submit. Submit without a value to see the required error, type a date in September to see the bound error, then reset.
import { useState } from 'react';import type { SubmitEvent } from 'react';import { Button } from '@slotted/react/button';import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldError, FieldLabel } from '@slotted/react/field';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';import { compareDateTime, plainDate, plainDateTime, plainTime, type PlainDateTime,} from '@slotted/core/date';const EARLIEST = plainDateTime(plainDate(2026, 10, 1), plainTime(8, 0));export default function DateTimePickerForm() { const [pickup, setPickup] = useState<PlainDateTime | null>(null); const [submitted, setSubmitted] = useState(false); const [saved, setSaved] = useState<string | null>(null); const error = pickup !== null && compareDateTime(pickup, EARLIEST) < 0 ? 'Choose October 1, 2026 at 8:00 AM or later.' : submitted && pickup === null ? 'Choose a pickup date and time.' : ''; const submit = (event: SubmitEvent<HTMLFormElement>) => { event.preventDefault(); setSubmitted(true); const value = new FormData(event.currentTarget).get('pickupAt'); const valid = pickup !== null && compareDateTime(pickup, EARLIEST) >= 0; setSaved(valid ? `Pickup booked for ${String(value)}.` : null); }; const reset = () => { setPickup(null); setSubmitted(false); setSaved(null); }; return ( <form noValidate onReset={reset} onSubmit={submit}> <Stack gap={5}> <Field invalid={error === '' ? undefined : true} required> <FieldLabel>Pickup date and time</FieldLabel> <DateTimePicker min={EARLIEST} name="pickupAt" onValueChange={setPickup} referenceDateTime={EARLIEST} value={pickup} /> <FieldError live="polite" reserve> {error} </FieldError> </Field> <Inline align="center" gap={3}> <Button type="submit">Book pickup</Button> <Button tone="secondary" type="reset" variant="outline"> Reset </Button> {saved && ( <Text size="sm" tone="muted"> {saved} </Text> )} </Inline> </Stack> </form> );}Keyboard and the trigger’s name
Alt+ArrowDown opens the panel from the field and leaves focus in the field, so typing keeps working. The calendar button opens it with Enter, Space or ArrowDown and moves focus to the chosen day. Tab and Shift+Tab move between the shortcuts, the calendar, the clock and the footer until the panel closes. In the clock, the arrow keys move between hours and between minutes, and Home and End move to the first and last one. Enter or Space chooses, and Ctrl+Enter applies. Escape closes the panel, discards the draft and returns focus to the calendar button; while the calendar shows months or years, Escape first returns to the days. The button’s accessible name carries the chosen date and time, and messages replaces it: choose while no value is set and change, with the value in its {date} slot, once one is. onOpenChange in React and (openChange) in Angular report why the panel opened or closed.
Focus the field and press Alt+ArrowDown.
import { useState } from 'react';import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';export default function DateTimePickerKeyboard() { const [last, setLast] = useState('Focus the field and press Alt+ArrowDown.'); return ( <Field> <FieldLabel>Dispatch</FieldLabel> <DateTimePicker defaultValue={plainDateTime(plainDate(2026, 9, 30), plainTime(16, 30))} messages={{ choose: 'Choose dispatch time', change: 'Change dispatch time, {date}' }} onOpenChange={(open, request) => setLast(`${open ? 'Opened' : 'Closed'} by ${request.reason}.`) } /> <FieldDescription>{last}</FieldDescription> </Field> );}Narrow screens
Under 760 pixels, the panel shows the month or the clock, one at a time. The day and the time stay written at the head of each, and a press on a head brings its part; a press on a day moves to the clock. The shortcuts become a strip. Under 480 pixels on a touch screen, the panel opens as a sheet attached to the bottom of the viewport, and the positioner carries data-presentation="sheet".
import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldLabel } from '@slotted/react/field';import { addDays, plainDate, plainDateTime, plainTime } from '@slotted/core/date';const TODAY = plainDate(2026, 9, 30);export default function DateTimePickerNarrow() { return ( <Field> <FieldLabel>Delivery appointment</FieldLabel> <DateTimePicker presets={[ { label: 'End of today', value: plainDateTime(TODAY, plainTime(17, 0)) }, { label: 'Tomorrow early', value: plainDateTime(addDays(TODAY, 1), plainTime(9, 0)) }, ]} referenceDateTime={plainDateTime(TODAY, plainTime(9, 0))} step={1800} /> </Field> );}Carrier pickup slot
A carrier collects in four fixed windows on weekdays, and each window takes three trucks. options lists the windows, isTimeUnavailable refuses a full window on its own day, and renderSlot in React or an ng-template with slClockSlot in Angular writes the trucks left in each one. The slot receives the time, its label, its state and the day in the draft. The button keeps its role, its states and its keyboard; only its content is yours.
Harbor Freightways collects on weekdays. Each window says the trucks left.
import { useState } from 'react';import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { createDateTimeFormat, dayOfWeek, plainDate, plainDateTime, plainTime, toISODate, toISOTime, type PlainDate, type PlainDateTime, type PlainTime,} from '@slotted/core/date';/** The windows Harbor Freightways collects in, every weekday. */const WINDOWS = [plainTime(8, 0), plainTime(10, 30), plainTime(13, 0), plainTime(15, 30)];const TRUCKS_PER_WINDOW = 3;/** Pickups already booked, by date and window. */const BOOKED: Record<string, number> = { '2026-10-01T08:00:00': 3, '2026-10-01T10:30:00': 2, '2026-10-02T13:00:00': 3, '2026-10-02T15:30:00': 1,};const words = createDateTimeFormat({ locale: 'en-US' });const trucksLeft = (time: PlainTime, date: PlainDate) => TRUCKS_PER_WINDOW - (BOOKED[`${toISODate(date)}T${toISOTime(time)}`] ?? 0);const isWeekend = (date: PlainDate) => dayOfWeek(date) === 0 || dayOfWeek(date) === 6;export default function DateTimePickerCarrierPickup() { const [pickup, setPickup] = useState<PlainDateTime | null>(null); return ( <Field required> <FieldLabel>Carrier pickup slot</FieldLabel> <DateTimePicker hourCycle={24} isDateUnavailable={isWeekend} isTimeUnavailable={(time, date) => trucksLeft(time, date) === 0} min={plainDateTime(plainDate(2026, 10, 1), plainTime(8, 0))} onValueChange={setPickup} options={WINDOWS} referenceDateTime={plainDateTime(plainDate(2026, 10, 1), plainTime(10, 30))} renderSlot={({ date, label, time, unavailable }) => date === null || unavailable ? label : `${label} (${String(trucksLeft(time, date))})` } value={pickup} /> <FieldDescription> {pickup === null ? 'Harbor Freightways collects on weekdays. Each window says the trucks left.' : `Harbor Freightways collects on ${words.describe(pickup)}.`} </FieldDescription> </Field> );}Publish at a set time
A price list goes live at a set time in New York. min stops the reader before the moment the form opened, presets adds the two times the team uses most after Now, and timeZone makes today and Now follow New York. The value stays a wall-clock time; the description names the zone, so the reader and your server read it the same way.
Prices go live on October 1, 2026 at 9:00 AM, New York time.
import { useState } from 'react';import { DateTimePicker } from '@slotted/react/datetime-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { addDays, createDateTimeFormat, dayOfWeek, plainDate, plainDateTime, plainTime, type PlainDateTime,} from '@slotted/core/date';const NOW = plainDateTime(plainDate(2026, 9, 30), plainTime(9, 0));const TOMORROW = plainDateTime(addDays(NOW.date, 1), plainTime(9, 0));const NEXT_MONDAY = plainDateTime( addDays(NOW.date, (8 - dayOfWeek(NOW.date)) % 7 || 7), plainTime(9, 0),);const words = createDateTimeFormat({ locale: 'en-US' });export default function DateTimePickerPublishAt() { const [publishAt, setPublishAt] = useState<PlainDateTime | null>(TOMORROW); return ( <Field required> <FieldLabel>Publish the autumn price list at</FieldLabel> <DateTimePicker min={NOW} onValueChange={setPublishAt} presets={[ { label: 'Tomorrow', value: TOMORROW }, { label: 'Monday', value: NEXT_MONDAY }, ]} referenceDateTime={NOW} timeZone="America/New_York" value={publishAt} /> <FieldDescription> {publishAt === null ? 'Choose when the new prices go live, New York time.' : `Prices go live on ${words.describe(publishAt)}, New York time.`} </FieldDescription> </Field> );}Accessibility
| Key | Effect | Focus |
|---|---|---|
| Alt+ArrowDown | open | stays in the field, so typing keeps working |
| ArrowDown | the trigger opens the panel | the chosen day, or today |
| ArrowUp | the trigger opens the panel | the chosen day, or today |
| Ctrl+Enter | apply | — |
| Escape | close | trigger |
| Tab | contained | — |
- The trigger says aria-haspopup="dialog" and its name carries the value written, which is where focus returns when the panel closes.
- The panel is a dialog with its Tab wrapped, and each grid inside it is one stop.
- Escape discards the draft and returns focus to the trigger. Ctrl+Enter applies from anywhere in the panel.
- The footer’s hint is a status region, so the reason Apply is off is spoken as well as drawn.
- Alt+ArrowDown opens the panel and leaves focus in the field, so the segments keep every key they had.
- The clock answers the day in the draft, so a reader who moves to a closed day hears its hours as unavailable before they choose one.
- Under 760 pixels each head is a button with aria-expanded, so the part that is not on screen is announced as collapsed and not as missing.
API
DateTimePicker
Props
valuePlainDateTime | null- The moment held. Present means the consumer owns it.
defaultValuePlainDateTime | nullDefaultnull- What it starts from, and returns to on a form reset. Read once.
minPlainDateTime- The earliest accepted moment.
maxPlainDateTime- The latest accepted moment.
minTimePlainTime- The earliest time of every day inside the range.
maxTimePlainTime- The latest time of every day inside the range.
isDateUnavailable(date: PlainDate) => boolean- Refuses particular dates.
isTimeUnavailable(time: PlainTime, date: PlainDate) => boolean- Refuses particular times of a day.
stepnumberDefault900- Seconds between two offered times, counted from the first of the day.
optionsreadonly PlainTime[]- The times there are, stated rather than stepped.
presetsreadonly PickerPreset<PlainDateTime>[]- The consumer’s own shortcuts, after Now.
offsetsreadonly number[]Default [3600, 14400, 86400]- Steps from now, in seconds. An empty list draws none.
confirmbooleanDefaulttrue- Whether the panel keeps a draft until Apply.
granularity'hour' | 'minute' | 'second'Defaultminute- The finest unit written.
hourCycle12 | 24Default the locale’s- The clock the moment is written on.
referenceDateTimePlainDateTimeDefaultnow- The moment it is: what an empty field steps from, and what the panel counts distances and steps from.
relativebooleanDefaulttrue- Whether + and - open the duration expression in the field.
weekNumbersbooleanDefaultfalse- Draws the ISO week number.
firstDayOfWeeknumberDefault the locale’s- 0 is Sunday.
calendar'gregory'Defaultgregory- The calendar system.
namestring- The name a form posts the moment under.
invalidboolean- Stated by the consumer; a moment that fails a rule is invalid without it.
openboolean- Whether the panel is showing. Present means the consumer owns it.
defaultOpenbooleanDefaultfalse- Whether it starts open when nobody else says. Read once.
placement'bottom-start' | 'bottom' | 'bottom-end' | 'top-start' | 'top' | 'top-end'Defaultbottom-start- Where the panel opens, before the positioner has read the room.
size'sm' | 'md' | 'lg'Defaultmd- The height of the control. The field around it answers when the picker does not.
variant'outline' | 'subtle' | 'plain'Defaultoutline- How the control draws its frame.
localestringDefault the language in force- BCP 47. Writes the field, the panel and the trigger’s name.
timeZonestringDefault the runtime’s- Which zone answers "what is now".
todayPlainDateDefault the clock’s- The day it is: the mark of today, the date of Now, and the empty panel’s month.
disabledboolean- Answers no key and no press.
readOnlyboolean- Readable and not changeable.
requiredboolean- The form needs a value.
clearablebooleanDefaultfalse- Draws a clear on the control and in the panel, unless required.
messagesPartial<DatetimePickerMessages>- Words laid over the language in force: the trigger’s names, and what is said of a refused moment.
Events
| Name | Payload | When |
|---|---|---|
onValueChange | (value: PlainDateTime | null, request: ChangeRequest<PlainDateTime | null>) | Before the value moves, and cancellable: from a key in the field, from Apply, from Clear. |
onOpenChange | (open: boolean, request: ChangeRequest<boolean>) | Before the panel opens or closes, with the reason. |
Composition
DateTimePickerDefaultsProvidercomponent- On applicationSets calendar, confirm, granularity, hourCycle, placement, size, step, timeZone, today and variant once.
footerReactNodeDefault the step- What the footer says when nothing is wrong.
renderSlot(state: ClockSlotState) => ReactNodeDefault the time- What one whole time of options draws.
render(props: DateTimePickerRootProps) => ReactNode- Substitutes the element the root renders.
refRef<DateTimePickerHandle>- focus(), open() and close().
Parts
| Part | Element | Required | Purpose |
|---|---|---|---|
root | div, or the element render returns | Yes | The frame of the picker. Carries data-ui="datetime-picker", data-granularity, data-size, data-variant, data-open and the state attributes. |
control | div | Yes | The box the panel hangs from, around the field and the trigger. |
trigger | button | Yes | The button that opens the panel. Its name carries the moment written. |
Theming
Each token is a CSS custom property: set it in a theme, or on any element to retune every datetime picker inside it.
Datetime Picker tokens
| Token | Default |
|---|---|
--slotted-datetime-picker-invalid-focus-ring-color | var(--slotted-focus-ring-color-invalid, Highlight) |
--slotted-datetime-picker-radius | var(--slotted-control-radius, 4px) |
--slotted-datetime-picker-trigger-active-background | var(--slotted-tone-secondary-subtle-active) |
--slotted-datetime-picker-trigger-color | var(--slotted-text-muted, GrayText) |
--slotted-datetime-picker-trigger-hover-background | var(--slotted-tone-secondary-subtle-hover) |
--slotted-datetime-picker-trigger-size | min( calc(var(--_icon-size) + 2 * var(--slotted-space-2, 0.25rem)), calc( var(--_height) - var(--slotted-control-border-width, 1px) * 2 - var(--slotted-space-2, 0.25rem) ) ) |
Theme tokens it reads
| Token | Default |
|---|---|
--slotted-control-border-width | var(--slotted-border-width-thin) |
--slotted-control-height-lg | comfortable 38px · compact 32px · dense 30px |
--slotted-control-height-md | comfortable 34px · compact 28px · dense 26px |
--slotted-control-height-sm | comfortable 30px · compact 26px · dense 24px |
--slotted-control-icon-size-lg | comfortable 18px · compact 16px · dense 14px |
--slotted-control-icon-size-md | comfortable 16px · compact 14px · dense 13px |
--slotted-control-icon-size-sm | comfortable 14px · compact 13px · dense 12px |
--slotted-control-radius | var(--slotted-radius-sm) |
--slotted-control-transition-duration | var(--slotted-duration-short) |
--slotted-control-transition-easing | var(--slotted-easing-standard) |
--slotted-disabled-foreground | Set per scheme by the theme |
--slotted-focus-ring-color | Set per scheme by the theme |
--slotted-focus-ring-color-invalid | Set per scheme by the theme |
--slotted-focus-ring-offset | var(--slotted-border-width-thick) |
--slotted-focus-ring-width | var(--slotted-border-width-thick) |
--slotted-space-2 | 0.25rem |
--slotted-target-comfortable | 44px |
--slotted-target-min | 24px |
--slotted-text-muted | Set per scheme by the theme |
--slotted-tone-secondary-subtle-active | Set per scheme by the theme |
--slotted-tone-secondary-subtle-hover | Set per scheme by the theme |