Skip to content

Date and time picker ​

One field for a day and a time: one trigger, one popover, one Date out.

Open in demo
Open in demo

Usage ​

v-model is a Date, or undefined for no value. Two separate boxes would ask whoever wrote the form to recombine them on submit, which is how bookings end up in the wrong hour.

The trigger prints the value in the app's language, the date and the time joined by a space, so it reads like the table cell it edits.

Picking a day keeps the time already set. Picking a time before any day has been chosen lands on today, so the press has a visible result the reader can correct, rather than being dropped.

The time columns follow the language the same way the time picker does: 1–12 with AM/PM where the language writes a 12-hour clock, 0–23 and no third column where it does not.

Examples ​

Empty ​

Steps and a starting hour ​

minuteStep thins the minute column. defaultHour is the hour used when a day is picked before any time; it is a literal rather than "now", so the control renders the same every time.

Disabled ​

API ​

Source: src/shared/components/common/SaDateTimePicker.vue

Props ​

PropTypeDefaultDescription
modelValueDate | undefinedrequiredThe value. An invalid Date is treated as no value.
idstring—Put on the trigger, so a <Label for> points at it.
placeholderstring'common.pickADateAndTime'The trigger text while there is no value. The default renders as "Pick a date and time".
disabledbooleanfalseBlocks the trigger.
invalidbooleanfalseSets aria-invalid on the trigger.
requiredboolean—Sets aria-required on the trigger.
describedBystring—Sets aria-describedby on the trigger.
minuteStepnumber1The step between offered minutes. The value's own minute is always offered too.
defaultHournumber9The hour used when a day is picked and no time is set yet.

Emits ​

EventPayloadDescription
update:modelValuevalue: Date | undefinedFires on a day press and on every hour, minute or AM/PM press. Seconds and milliseconds are set to zero.

Slots ​

None.

Accessibility ​

  • The calendar is the shared calendar, so the week starts on the day the app's language starts on, and the grid answers to the arrow keys, Home, End, PageUp and PageDown.
  • Each time column is a listbox, named "Hour", "Minute" and "AM or PM", and every cell is an option carrying aria-selected.
  • Opening the popover scrolls the columns to the selected rows.
  • The trigger takes aria-invalid, aria-required and aria-describedby from the props of the same names.
  • A Done button closes the popover, so the interaction can be finished from the keyboard without hunting for the trigger.