Skip to content
SENVENLI UI

Time field

A typed time in the locale's clock, with minute steps and an optional time zone.
A typed time
import { TimeField } from "@senvenli/react/date";

Examples

Minute steps and a 24-hour clock

Arrow keys move the minutes a quarter of an hour at a time.

In another time zone

The zone is named after the time when it differs from the visitor's, so the label appears once the page runs in the browser.

Guidelines

When to use it

  • Typing a time of day.

Use something else when

  • Only certain times are available: a card RadioGroup of them (see its time-slots example). Radio group

Accessibility

Keyboard

KeysWhat happens
Arrow up / downChanges the focused part.

Built in

  • Required fields show "Fill in this field."; a partly typed date says what is missing.

You provide

  • A visible label.

API reference

TimeField

labelRequired
React.ReactNode

Always given; the label sits above the field and names its segments.

description
React.ReactNode
errorMessage
React.ReactNode

What happened and what to do; shown when the field is invalid.

isRequired
boolean
requiredValidation
RequiredValidation

Who says an empty required field is missing: field (default) or app. With app a DS Form's onSubmit runs with the field empty, and the app's own error must clear on change. See {@link RequiredValidation} for the whole contract.

isOptional
boolean

Shows "(optional)" when most of the form is required.

isDisabled
boolean
isReadOnly
boolean
isInvalid
boolean

Marks the field invalid from outside (a server error); errorMessage says why.

id
string

The id of the field's first typed segment (day, or the locale's first part), the element that takes focus : document.getElementById(id).focus() puts the user in the field, as a focus-on-error does. The field's group gets an id of its own. Left out, the DOM is as before.

name
string

The form field name; the value is submitted as an ISO string.

autoFocus
boolean
onBlur
(event: FocusEvent<Element, Element>) => void
value
TimeValue

A time, or a zoned date-time when a location's zone travels with it.

While the user leaves a time typed in part ("10:––"), the field reports onChange(null) and keeps the typed parts on screen, so setting null changes nothing: the value already is null. To clear the field (an app's own "Temizle" or form reset), give it a new key along with the value: React remounts it empty, or at the value given .

defaultValue
TimeValue
onChange
(value: TimeValue | null) => void
hourCycle
12 | 24

24-hour in tr and me, 12-hour in en-US; from the locale unless set.

granularity
"hour" | "minute"
minuteStep
number

Arrow keys step the minutes by this much (15 or 30).

timeZone
string

The location's zone (IANA, "Europe/Lisbon"). Named after the time when it differs from the user's.

minValue
TimeValue
maxValue
TimeValue
validate
(value: TimeValue | null) => string | true | string[] | null | undefined