Time field
A compact field that takes what people type, with the time picker a press away.
import { TimeField } from '@windmorph/react';Props
TimeField 34 props
The field's label, e.g. "Opens at".
The time (controlled);
nullfor none.Initial time when uncontrolled.
Earliest time allowed.
Latest time allowed.
12- or 24-hour clock, for the field and the picker. Left out, the locale's.
The field's style.
Where the picker opens.
dialogis the M3 time picker in a dialog.dockedis a list of times under the field (everystepminutes, withinminandmax) on windows 600px wide or more, for forms with many times; narrower windows still get the dialog. Not in the M3 spec, which has no docked time picker.Minutes between the times a docked list offers, counted from midnight; 5 at least. It only shapes the list: any time can still be typed.
Whether the picker is open (controlled).
Whether the picker starts open when uncontrolled.
Helper text below the field.
Marks the field invalid, with
errorMessagebelow it.Error text shown below the field while it's invalid, in place of
supportingText.The field must have a time.
The field and its clock button can't be used.
The time can be read and focused but not changed.
Read as
invalidwhen that's left out, for a form library that sets the attribute.Read as
requiredwhen that's left out, for a form library that sets the attribute.Read as
readOnlywhen that's left out, for a form library that sets the attribute.Form field name; the input submits the time as shown.
The
<input>'s id, for a<label for>or an error summary's link.Icon of the button that opens the picker.
Web density of the field,
0to-3: each step takes 4px off it (56px at 0, 48px at -2). The picker keeps its size. Left out, the field takes the nearest theme's.The text field's root.
The
<input>.
Events
A time was typed and committed, or picked and confirmed;
nullwhen cleared.Called when the picker opens or closes.
Text
More description for the
<input>, after the supporting or error text.The id of an element with more details about the
<input>.Words the field and its picker show and announce, with English defaults. A
LabelsProvidersets them for the whole app.The field's placeholder.
Error when the text isn't a time.
Error for a time before
minor aftermax.The clock icon button.
The picker's title and name.
The picker's dismissing action.
The picker's confirming action.
Name of the hour selector and field.
Name of the minute selector and field.
The AM option.
The PM option.
Name of the AM / PM selector.
Name of the dial.
TimePickerModeToggle's name in dial mode.TimePickerModeToggle's name in input mode.labels.dialValuetype(value: string, total: number, unit: "hours" | "minutes") => stringdefault${value} ${unit} of ${total}Name of a number on the dial (M3: "{Value} Hours or minutes of {Total}"), e.g. "7 hours of 12" or "35 minutes of 60".
valueis the number as the dial shows it ("05"), so the name holds the visible text (WCAG 2.5.3).The full-screen close (x) button.
The full-screen confirm button.
Classes for the root element, merged with
classNames.root; consumer classes win.Inline styles for the root element.
Classes for each part, by slot.
The text field's root;
classNamegoes here too.The docked list of times: its surface.
Each time of the docked list.
The picker dialog's surface.
The
<input>or<textarea>.The floating label.
The filled or outlined container around the label, input and icons.
The built-in error icon.
The outlined field's border (a
<fieldset>, notched for the floated label).The trailing icon's 48px box.
The helper text below the field.
The error message below the field.
The filled field's active indicator, the line along the container's bottom.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
Spec status
Built to the M3 Expressive time field spec. Each item of its variants and configurations links to a live example; where the M3 Expressive column of the spec differs from the original M3 one, it wins.
Bundle size
Gzipped, as published: the component and the library code it imports. React, React Aria, Motion and the other dependencies aren't counted, and your bundler's minifier makes it smaller still. CI fails a change that grows it past its budget.
TimeField: 40.2 kB
Theming & tokens
It has no tokens of its own: M3 has no time field, so the field and button take the text field's and icon button's tokens, and the docked list the menu's.