View as Markdown

API reference: @salmonui/calendars/date-field

TimeFieldcomponent

import { TimeField } from '@salmonui/calendars/date-field';

Also exported from @salmonui/calendars/time-picker.

function TimeField(props: TimeFieldProps): import("react").JSX.Element;

A segmented time input: one spinbutton per segment, in the locale's order and hour cycle.

Props: TimeFieldProps

TimeField props (31)
NameSignatureDescription
granularityoptionalreadonly granularity?: 'hour' | 'minute' | 'second';

Deepest segment. Default 'minute'.

valueoptionalreadonly value?: TimeInput | null;
defaultValueoptionalreadonly defaultValue?: TimeInput | null;
onValueChangeoptionalreadonly onValueChange?: (value: PlainTime | null, details: FieldChangeDetails) => void;
minoptionalreadonly min?: TimeInput;
maxoptionalreadonly max?: TimeInput;
placeholderValueoptionalreadonly placeholderValue?: TimeInput;

Seeds Up / Down on empty segments (default: now, read in the event handler).

isTimeDisabledoptionalreadonly isTimeDisabled?: (time: PlainTime) => boolean;

Rejects single times (the field becomes invalid).

refoptionalinheritedref?: Ref<HTMLDivElement>;
sizeoptionalinheritedsize?: "lg" | "md" | "sm";

Control size: 'sm' 24px, 'md' 32px (default), 'lg' 40px tall; data-size on the group.

labeloptionalinheritedlabel?: ReactNode;

Visible label above the segments; also names the group.

descriptionoptionalinheriteddescription?: ReactNode;
errorMessageoptionalinheritederrorMessage?: ReactNode;

Shown when invalid (or a complete value is out of range / disabled).

formatoptionalinheritedformat?: DateFormat;

Display format: Intl options, a CLDR skeleton ('yMMMd') or a pattern ('dd/MM/yyyy', 'HH:mm'); the segments follow it.

hourCycleoptionalinheritedhourCycle?: HourCycle;

'h12' or 'h23'; default from the locale.

localeoptionalinheritedlocale?: string;

BCP 47 locale. Default 'en-US'; the host locale is never read.

timeZoneoptionalinheritedtimeZone?: string;

IANA zone for Date and offset inputs, and details.epochMilliseconds.

inputFormatsoptionalinheritedinputFormats?: readonly string[];

Extra accepted paste and typed formats (patterns); ISO is always accepted.

parseoptionalinheritedparse?: ParseFn;

Custom text parser, tried last.

strictoptionalinheritedstrict?: boolean;

false (default): an out-of-range or disabled value is kept and the field is aria-invalid. true: on blur, incomplete or disabled input reverts to the last valid value and an out-of-range value moves to the nearest bound.

disabledoptionalinheriteddisabled?: boolean;
readOnlyoptionalinheritedreadOnly?: boolean;
requiredoptionalinheritedrequired?: boolean;
invalidoptionalinheritedinvalid?: boolean;
autoFocusoptionalinheritedautoFocus?: boolean;
nameoptionalinheritedname?: string;

Form field name: a visually hidden input posts the ISO value.

formoptionalinheritedform?: string;
onFocusoptionalinheritedonFocus?: ((event: FocusEvent<HTMLDivElement, Element>) => void);

Fires once when focus enters the group.

onBluroptionalinheritedonBlur?: ((event: FocusEvent<HTMLDivElement, Element>) => void);

Fires once when focus leaves the group.

localeTextoptionalinheritedlocaleText?: Partial<FieldLocaleText>;
diroptionalinheriteddir?: "ltr" | "rtl";

Direction override; inherited from the document by default.