Date time input - Usage

- Label
- Required field indicator
- Current date and time value
- Calendar icon button
- Input field
- Date time picker
- Month and year navigation
Options
- Label: See form field.
- Required: See form field.
- Helper text: See form field.
- Feedback text: See form field.
- Show text as tooltip: See form field.
- Placeholder: See form field. We typically use a placeholder to show an example date time format to assist users when the field is empty.
- Text alignment: See form field (by default at start).
- Error message: Feedback text when date or time is not parsable. We typically use this to inform users that the entered date time format is incorrect and guide them to enter a valid date and time.
- Format: Choose the date and time format, e.g.
yyyy/LL/ddandHH:mm:ss. - Min and max dates: Restrict the selectable date range by defining the earliest and latest dates users can choose.
- Require confirmation: Define if dates and times selected in the date time picker are applied directly after selection or on clicking the confirm button.
- Date time picker appearance: See date time picker.
- Week start: Define which day the week starts on. By default, it will be defined based on the locale.
- Week numbers: Show calendar weeks on the left side of the calendar when needed for reference.
Behavior in context
- Interaction:
- Click opens date time pickers. Via keyboard focus followed by arrow down key also opens it.
- Use mouse or keyboard arrows to navigate to the desired date and adjust the time.
- Done closes the date time picker. With
requireConfirmationset, confirm applies the selection and closes the date time picker. - Typing a valid date and time into input field applies the value immediately, emits
valueChangeand closes the picker, regardless of require confirmation. Require confirmation only applies to values selected in the date time picker. - Escape key closes the date time picker.
- Validation:
- Use feedback text for validation types valid, info, warning and invalid.
- Invalid feedback is automatically provided if the entered date or time is not parsable.
- Refer to the validation chapter for detailed guidelines.
- Overflow: The input field should be wide enough to display the full date and time without truncation.
- Alignment: Date time inputs are aligned to the left by default.
- Combined selection: Users select both a date and a time. With require confirmation, the selection is only applied when the confirm button is clicked. Clicking the cancel button or outside the picker, or pressing the
Escapekey reverts any pending selections. The done and confirm buttons are disabled while no date is picked or the value is unchanged.
States
Date time input has five states: Default, hover, disabled, read-only and focused.

Dos and Don’ts
- Do use consistent date and time formats throughout the application to avoid confusion
- Do provide clear instructions on the expected format, such as "Enter the date time in yyyy/mm/dd HH:mm format"
- Do consider localization to adapt date and time formats to local conventions
- Do use separate inputs for start and end date times when defining time ranges
- Don't use date time inputs when only a date or only a time is needed (use date input or time input instead)