Skip to content
Focsd homeFocsd homeFocsd
Forms

Date and time picker

A date and a time chosen together: type both, or pick them in one dialog.

  • Tag: focsd-date-time-picker
  • Pattern: Group: date input + dialog (calendar, time) + time field
  • Category: Forms

Example

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

API

Attributes

AttributePropertyTypeDefault
labellabelstring—
valuevaluestring—
minminstring—
maxmaxstring—
localelocalestring—
stepstepnumber1
hour-cyclehourCycle'h12' | 'h23' | ''—
namenamestring—
disableddisabledbooleanfalse
requiredrequiredbooleanfalse
readonlyreadOnlybooleanfalse
aria-labelhostAriaLabelstring | nullnull
aria-descriptionhostAriaDescriptionstring | nullnull
aria-labelledbyhostAriaLabelledBystring | nullnull
aria-describedbyhostAriaDescribedBystring | nullnull
label-positionlabelPosition'top' | 'start' | 'end' | undefined—
hinthintstring—
errorerror——
warningwarningstring | undefined—
successsuccessstring | undefined—
error-messageerrorMessagestring | undefined—
warning-messagewarningMessagestring | undefined—
warning-patternwarningPatternstring | undefined—
autocompleteautocompleteAutoFilloff

Methods

MethodDescription
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

EventDescription
inputFired on every user edit of the value.
changeFired 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).

PartDescription
timeThe time field, inline and in the dialog.
doneThe dialog's Done button.
calendarThe calendar inside the dialog.
calendar-dayCalendar parts, re-exported with a `calendar-` prefix (calendar-day, calendar-nav, calendar-heading, calendar-grid, calendar-weekday, calendar-today, calendar-selected, …).
panelThe dialog's content: the calendar, any extra fields and the actions.
actionsThe row of dialog buttons at the bottom.
cancelThe dialog's Cancel button (also exposed as `close`).
closeThe dialog's Cancel button (kept for existing stylesheets).
controlThe control element.
dialogThe dialog element.
fieldThe field element.
labelThe label element.
layoutThe wrapper that places the label beside or above the body.
bodyThe control, hint and message.
hintThe author hint followed by the date format.
messageThe shown error, warning or success message (also `error`, `warning` or `success`).
message-iconThe message's icon.
announcerThe visually hidden status region.
triggerThe 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 native datetime-local input; your app converts it to or from a zone or UTC.
  • min and max use the same format and compare the whole timestamp, so 2026-03-01T07:45 is before a min of 2026-03-01T08:00. step is in minutes and sets how far the arrow keys move the minutes. Values have minute precision: seconds in value, min or max (09:30:59) are accepted and dropped.
  • A date without a time, or a time without a date, reports "Enter a date and time." required reports the same message when both are empty.
  • Form-associated: participates in FormData, validation, reset, fieldset disabled and back/forward restore.

Keyboard

KeyAction
TabDate 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
EscapeClose the dialog without changing the value