TimeField

Data input

A time of day typed segment by segment, in the locale's format: <TimeField.Root> (bind:value a Time from @limerdev/zest, granularity hour, minute or second, hourCycle 12 or 24, minValue, maxValue, name) holds a TimeField.Label (which names the field; use it instead of Field.Label) and a TimeField.Input, which draws its segments. Type digits or use the arrow keys. Inside a Field, its Field.Description and Field.Error describe the field.

import { TimeField } from '@limerdev/zest';
TimeField for AI tools (llms.txt)
Use for
A time people type: when a shift starts, a meeting time, a reminder.
Don't
A date and a time together: use DateField with granularity="minute". A duration (hours worked): use Input type="number".

Examples

Basic

A 24-hour time. Type digits or use the arrow keys in a segment.

Shift starts
0900

Props

Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that renders your own element, with props to spread on it).

TimeField.Root

Prop Type Default Description
disabled boolean false If true, the time field will be disabled and users will not be able to interact with it. This also disables the hidden input element if the time field is used in a form.
errorMessageId string – The id of the element which contains the error messages for the time field when the time is invalid.
granularity "hour" | "minute" | "second" 'minute' The granularity of the time field. This determines which segments will be includes in the segments array used to build the time field. Granularity is only used for visual purposes, and does not impact the value of the time field. You can have the same value synced between multiple time fields with different granularities and they will all contain the same value.
hideTimeZone boolean false; Whether or not to hide the timeZoneName segment from the time field.
hourCycle 12 | 24 the locale's default time format The format to use for displaying the time in the input. If using a 12 hour clock, ensure you also include the dayPeriod segment in your input to ensure the user can select AM/PM.
locale string 'en' The locale to use for formatting the time field.
maxValue TimeValue – The maximum acceptable time. When provided, the time field will be marked as invalid if the user enters a time after this time.
minValue TimeValue – The minimum acceptable time. When provided, the time field will be marked as invalid if the user enters a time before this time.
onInvalid TimeOnInvalid – A callback fired when the time field's value is invalid. Use this to display an error message to the user.
onPlaceholderChange OnChangeFn<TimeValue | undefined> – A callback that is called when the time field's placeholder value changes.
onValueChange OnChangeFn<Time | undefined> – A callback that is called when the time field value changes.
placeholder bindable TimeValue – The placeholder value of the time field. This determines the format and what time the field starts at when it is empty.
readonly boolean false If true, the time field will be readonly, and users will not be able to edit the values of any of the individual segments.
readonlySegments ("month" | "year" | "day" | "hour" | "minute" | "second" | "dayPeriod")[] – An array of segment names that should be readonly. If provided, only the segments not in this array will be editable.
required boolean false Whether or not the hidden input of the time field requires a value to be submitted.
validate TimeValidator<Time> – A function that returns a string or array of strings as validation errors if the time is invalid, or nothing if the time is valid
value bindable Time – The value of the time field.

TimeField.Label

No props of its own beyond the common ones.

TimeField.Input

Prop Type Default Description
name string – The name to use for the hidden input element of the time field, which is used to submit the ISO string value of the time field to a server. If not provided, the hidden input element will not be rendered.

TimeField.Segment

Prop Type Default Description
part required "hour" | "minute" | "second" | "dayPeriod" | "timeZoneName" | "literal" –