<!-- index: /slotted/llms.txt -->
# datetime-picker

`data-ui="datetime-picker"` · Date and time field with a picker popover.

## Import

```tsx
import { DateTimePicker, DateTimePickerDefaultsProvider } from '@slotted/react';
```

## Minimal example

Example

```tsx
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>
  );
}
```

## Anatomy

| Part | Element | Required |
| --- | --- | --- |
| `root` | div, or the element render returns | yes |
| `control` | div | yes |
| `trigger` | button | yes |

## Props

| Name | Type | Default | Applies to | Description |
| --- | --- | --- | --- | --- |
| `value` | `PlainDateTime \| null` | — | DateTimePicker | The moment held. Present means the consumer owns it. |
| `defaultValue` | `PlainDateTime \| null` | null | DateTimePicker | What it starts from, and returns to on a form reset. Read once. |
| `min` | `PlainDateTime` | — | DateTimePicker | The earliest accepted moment. |
| `max` | `PlainDateTime` | — | DateTimePicker | The latest accepted moment. |
| `minTime` | `PlainTime` | — | DateTimePicker | The earliest time of every day inside the range. |
| `maxTime` | `PlainTime` | — | DateTimePicker | The latest time of every day inside the range. |
| `isDateUnavailable` | `(date: PlainDate) => boolean` | — | DateTimePicker | Refuses particular dates. |
| `isTimeUnavailable` | `(time: PlainTime, date: PlainDate) => boolean` | — | DateTimePicker | Refuses particular times of a day. |
| `step` | `number` | 900 | DateTimePicker | Seconds between two offered times, counted from the first of the day. |
| `options` | `readonly PlainTime[]` | — | DateTimePicker | The times there are, stated rather than stepped. |
| `presets` | `readonly PickerPreset<PlainDateTime>[]` | — | DateTimePicker | The consumer’s own shortcuts, after Now. |
| `offsets` | `readonly number[]` | [3600, 14400, 86400] | DateTimePicker | Steps from now, in seconds. An empty list draws none. |
| `confirm` | `boolean` | true | DateTimePicker | Whether the panel keeps a draft until Apply. |
| `granularity` | `'hour' \| 'minute' \| 'second'` | minute | DateTimePicker | The finest unit written. |
| `hourCycle` | `12 \| 24` | the locale’s | DateTimePicker | The clock the moment is written on. |
| `referenceDateTime` | `PlainDateTime` | now | DateTimePicker | The moment it is: what an empty field steps from, and what the panel counts distances and steps from. |
| `relative` | `boolean` | true | DateTimePicker | Whether + and - open the duration expression in the field. |
| `weekNumbers` | `boolean` | false | DateTimePicker | Draws the ISO week number. |
| `firstDayOfWeek` | `number` | the locale’s | DateTimePicker | 0 is Sunday. |
| `calendar` | `'gregory'` | gregory | DateTimePicker | The calendar system. |
| `name` | `string` | — | DateTimePicker | The name a form posts the moment under. |
| `invalid` | `boolean` | — | DateTimePicker | Stated by the consumer; a moment that fails a rule is invalid without it. |
| `open` | `boolean` | — | DateTimePicker | Whether the panel is showing. Present means the consumer owns it. |
| `defaultOpen` | `boolean` | false | DateTimePicker | Whether it starts open when nobody else says. Read once. |
| `placement` | `'bottom-start' \| 'bottom' \| 'bottom-end' \| 'top-start' \| 'top' \| 'top-end'` | bottom-start | DateTimePicker | Where the panel opens, before the positioner has read the room. |
| `size` | `'sm' \| 'md' \| 'lg'` | md | DateTimePicker | The height of the control. The field around it answers when the picker does not. |
| `variant` | `'outline' \| 'subtle' \| 'plain'` | outline | DateTimePicker | How the control draws its frame. |
| `locale` | `string` | the language in force | DateTimePicker | BCP 47. Writes the field, the panel and the trigger’s name. |
| `timeZone` | `string` | the runtime’s | DateTimePicker | Which zone answers "what is now". |
| `today` | `PlainDate` | the clock’s | DateTimePicker | The day it is: the mark of today, the date of Now, and the empty panel’s month. |
| `disabled` | `boolean` | — | DateTimePicker | Answers no key and no press. |
| `readOnly` | `boolean` | — | DateTimePicker | Readable and not changeable. |
| `required` | `boolean` | — | DateTimePicker | The form needs a value. |
| `clearable` | `boolean` | false | DateTimePicker | Draws a clear on the control and in the panel, unless required. |
| `messages` | `Partial<DatetimePickerMessages>` | — | DateTimePicker | Words laid over the language in force: the trigger’s names, and what is said of a refused moment. |
| `DateTimePickerDefaultsProvider` | `component` | — | application | Sets calendar, confirm, granularity, hourCycle, placement, size, step, timeZone, today and variant once. |
| `footer` | `ReactNode` | the step | DateTimePicker | What the footer says when nothing is wrong. |
| `renderSlot` | `(state: ClockSlotState) => ReactNode` | the time | DateTimePicker | What one whole time of options draws. |
| `render` | `(props: DateTimePickerRootProps) => ReactNode` | — | DateTimePicker | Substitutes the element the root renders. |
| `ref` | `Ref<DateTimePickerHandle>` | — | DateTimePicker | focus(), open() and close(). |

## 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. |

## Axes and defaults

| Axis | Values | Default |
| --- | --- | --- |
| `size` | `sm`, `md`, `lg` | `md` |
| `variant` | `outline`, `subtle`, `plain` | `outline` |
| `placement` | `bottom-start`, `bottom`, `bottom-end`, `top-start`, `top`, `top-end` | `bottom-start` |
| `hourCycle` | `12`, `24` | — |
| `granularity` | `hour`, `minute`, `second` | `minute` |
| `calendar` | `gregory` | `gregory` |
| `confirm` | `on`, `off` | true |

## Rules

- 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.

## Tokens

`--slotted-control-border-width`, `--slotted-control-height-lg`, `--slotted-control-height-md`, `--slotted-control-height-sm`, `--slotted-control-icon-size-lg`, `--slotted-control-icon-size-md`, `--slotted-control-icon-size-sm`, `--slotted-control-radius`, `--slotted-control-transition-duration`, `--slotted-control-transition-easing`, `--slotted-datetime-picker-invalid-focus-ring-color`, `--slotted-datetime-picker-radius`, `--slotted-datetime-picker-trigger-active-background`, `--slotted-datetime-picker-trigger-color`, `--slotted-datetime-picker-trigger-hover-background`, `--slotted-datetime-picker-trigger-size`, `--slotted-disabled-foreground`, `--slotted-focus-ring-color`, `--slotted-focus-ring-color-invalid`, `--slotted-focus-ring-offset`, `--slotted-focus-ring-width`, `--slotted-space-2`, `--slotted-target-comfortable`, `--slotted-target-min`, `--slotted-text-muted`, `--slotted-tone-secondary-subtle-active`, `--slotted-tone-secondary-subtle-hover`

## Examples

See [datetime-picker.examples.md](./datetime-picker.examples.md).
