Skip to content

Time field

A compact field that takes what people type, with the time picker a press away.

import { TimeField } from '@windmorph/react';

Purpose

The time sibling of DateField, for forms that hold many times, such as a weekly schedule: one compact field per time that takes what people type, with the TimePicker a press away. For a single, deliberate choice, a TimePicker in a PickerDialog alone suits.

Behaviour

  • It reads 9, 930, 0930, 9:30, 9.30, 9h30, 21:30, 9pm and 9:30 pm, with the locale's digits and day periods, and normalizes them on blur and Enter.
  • The 12- or 24-hour clock is the locale's: the nearest LocaleProvider's, or the browser's language without one, which may not be the page's. hourCycle sets it for one field.
  • Unreadable or out-of-range text stays as typed with an inline error, and the value is unchanged until it's put right. 9:3 is refused: it could mean 9:03 or 9:30.
  • value is a Time or null. Time and parseTime are exported, so an app needs no date library.
  • The picker opens from the clock, is full screen below 600px, and loads on demand, so a form of many fields carries none of it.
  • With presentation="docked" the clock opens a list of times under the field instead, on windows 600px wide or more: every half hour, or every step minutes, within min and max. It opens on the field's time, a press picks a time and closes it, and any other time can still be typed. Narrower windows keep the dialog. M3 has no docked time picker; this is the library's own.

When not to use

For a single, deliberate choice, a TimePicker in a PickerDialog alone suits.

See also

  • Time picker: Pick an hour and minute on a clock dial or by typing, 12- or 24-hour.
  • Date picker: Pick a single date or a range on a month grid or by typing, docked below a field or in a dialog.
  • Text field: Filled or outlined text input with a floating label, icons, affixes, counter, error icon and a text area.