Date and time picker
A date and a time chosen together: type both, or pick them in one dialog.
Example
<div class="stack"> <focsd-date-time-picker label="Meeting" name="meeting" value="2026-03-16T09:30" step="15" min="2026-03-01T08:00" max="2026-03-31T18:00" hour-cycle="h23"></focsd-date-time-picker> <focsd-date-time-picker label="Reminder" name="reminder" required hint="We send it at this time"></focsd-date-time-picker></div>Usage
Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.
<script type="module"> import '@focsd-dev/components/focsd-date-time-picker.js';</script>
<focsd-date-time-picker label="Meeting" name="meeting" value="2026-03-16T09:30" step="15" min="2026-03-01T08:00" max="2026-03-31T18:00" hour-cycle="h23"></focsd-date-time-picker>import { DateTimePicker } from '@focsd-dev/react';
export function Example() { return <DateTimePicker onChange={(e) => console.log(e.target)} label="Meeting" name="meeting" value="2026-03-16T09:30" step="15" min="2026-03-01T08:00" max="2026-03-31T18:00" hour-cycle="h23"></DateTimePicker>;}<script setup>import '@focsd-dev/components/focsd-date-time-picker.js';</script>
<template> <focsd-date-time-picker @change="onChange" label="Meeting" name="meeting" value="2026-03-16T09:30" step="15" min="2026-03-01T08:00" max="2026-03-31T18:00" hour-cycle="h23"></focsd-date-time-picker></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/components/focsd-date-time-picker.js';
// template<focsd-date-time-picker (change)="onChange($event)" label="Meeting" name="meeting" value="2026-03-16T09:30" step="15" min="2026-03-01T08:00" max="2026-03-31T18:00" hour-cycle="h23"></focsd-date-time-picker><script> import '@focsd-dev/components/focsd-date-time-picker.js';</script>
<focsd-date-time-picker onchange={(e) => console.log(e.target)} label="Meeting" name="meeting" value="2026-03-16T09:30" step="15" min="2026-03-01T08:00" max="2026-03-31T18:00" hour-cycle="h23"></focsd-date-time-picker>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
label | label | string | — |
value | value | string | — |
min | min | string | — |
max | max | string | — |
locale | locale | string | — |
step | step | number | 1 |
hour-cycle | hourCycle | 'h12' | 'h23' | '' | — |
name | name | string | — |
disabled | disabled | boolean | false |
required | required | boolean | false |
readonly | readOnly | boolean | false |
aria-label | hostAriaLabel | string | null | null |
aria-description | hostAriaDescription | string | null | null |
aria-labelledby | hostAriaLabelledBy | string | null | null |
aria-describedby | hostAriaDescribedBy | string | null | null |
label-position | labelPosition | 'top' | 'start' | 'end' | undefined | — |
hint | hint | string | — |
error | error | — | — |
warning | warning | string | undefined | — |
success | success | string | undefined | — |
error-message | errorMessage | string | undefined | — |
warning-message | warningMessage | string | undefined | — |
warning-pattern | warningPattern | string | undefined | — |
autocomplete | autocomplete | AutoFill | off |
Methods
| Method | Description |
|---|---|
describedByIds() | IDs to add to the inner control's aria-describedby: the hint, then the shown message. |
checkValidity() | True when the value is valid; otherwise fires invalid and returns false, like native. |
reportValidity() | Like checkValidity(), and also shows the browser's validation message when invalid. |
setCustomValidity(message) | Set (non-empty) or clear (empty string) a custom validation error, like native controls. |
setValidityState(flags, message, anchor) | For subclasses: set the validity flags and message. anchor is the element the browser points its message at. |
validate() | Show (or clear) the error from the control's own checks: required, type, pattern, min,
max and the like. Uses error-message, else the browser's localized message. An error the
author set (a server error, say) is left as it is. |
clearValidation() | Clear the error and warning that validate() and warning-pattern showed (a form reset does). |
emitValue(commit) | For subclasses: fire the value events, as a native control does on a user edit: input
(bubbles, composed), then with commit also change (bubbles, stays in its tree). |
idrefText(ids) | For subclasses: the text of the elements an ID reference list names, resolved in the host's tree (ID references cannot cross a shadow root), joined by spaces. |
showPicker() | Open the calendar from code, like native showPicker(). |
openDialog() | Open the calendar dialog and focus its active day. Does nothing while disabled or read-only. |
Events
| Event | Description |
|---|---|
input | Fired on every user edit of the value. |
change | Fired when the user commits a change to the value or state. |
CSS parts
Style the inside of the component with ::part(), for example focsd-date-time-picker::part(time).
| Part | Description |
|---|---|
time | The time field, inline and in the dialog. |
done | The dialog's Done button. |
calendar | The calendar inside the dialog. |
calendar-day | Calendar parts, re-exported with a `calendar-` prefix (calendar-day, calendar-nav, calendar-heading, calendar-grid, calendar-weekday, calendar-today, calendar-selected, …). |
panel | The dialog's content: the calendar, any extra fields and the actions. |
actions | The row of dialog buttons at the bottom. |
cancel | The dialog's Cancel button (also exposed as `close`). |
close | The dialog's Cancel button (kept for existing stylesheets). |
control | The control element. |
dialog | The dialog element. |
field | The field element. |
label | The label element. |
layout | The wrapper that places the label beside or above the body. |
body | The control, hint and message. |
hint | The author hint followed by the date format. |
message | The shown error, warning or success message (also `error`, `warning` or `success`). |
message-icon | The message's icon. |
announcer | The visually hidden status region. |
trigger | The trigger element. |
Accessibility
- One labeled
role="group"holds a text input named "Date", a "Choose date and time" button and a time field named "Time", so each part can be typed without opening the dialog. - The button opens a modal dialog named "Choose date and time" with the calendar, a second time field and a Done button. Picking a day keeps the dialog open; Done applies the day and time, closes it and returns focus to the button. Escape closes it and changes nothing.
- There is no time zone. The value is the local wall-clock time,
YYYY-MM-DDTHH:mm, as on a nativedatetime-localinput; your app converts it to or from a zone or UTC. minandmaxuse the same format and compare the whole timestamp, so2026-03-01T07:45is before aminof2026-03-01T08:00.stepis in minutes and sets how far the arrow keys move the minutes. Values have minute precision: seconds invalue,minormax(09:30:59) are accepted and dropped.- A date without a time, or a time without a date, reports "Enter a date and time."
requiredreports the same message when both are empty. - Form-associated: participates in
FormData, validation, reset, fieldsetdisabledand back/forward restore.
Keyboard
| Key | Action |
|---|---|
| Tab | Date input, then the dialog button, then the time segments |
| Arrow keys (calendar) | Move between days; Enter picks one and keeps the dialog open |
| Arrow Up / Down (time) | Change hours or minutes by step |
| Digits (time) | Type hours and minutes; moves on when complete |
| Escape | Close the dialog without changing the value |
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.