Components

Time Field

Locale-aware segmented time input with keyboard editing, constraints, granularity, and native forms.

TimeField renders locale-ordered hour, minute, second, and day-period controls. It supports 12/24-hour cycles, keyboard editing, paste, constraints, Field state, and native forms.

Use Time Field for editable clock values. Style generated segments through ui, semantic classes, data attributes, and slots.

TimeValue is Time | CalendarDateTime | ZonedDateTime from @internationalized/date. Install it beside Akaza UI when application code creates values: pnpm add akaza-ui @internationalized/date.

Anatomy

  • #literal: Locale separator content, such as : or spacing.
  • #day-period: AM/PM button content with canonical value, localized label, and toggle action.
  • #time-zone: Time-zone label content for ZonedDateTime values.

Time Field generates the root group, segment container, spinbutton inputs, locale literals, optional day-period button, optional time-zone label, and native form input.

Usage

Arrow keys step segments. Click AM/PM to switch periods.

Value: 09:30:00

Examples

12-hour and 24-hour cycles

Omit hourCycle to follow locale preference. Bind numeric 12 or 24 when product requirements must override it.

<TimeField v-model="time" :hour-cycle="12" />
<TimeField v-model="time" :hour-cycle="24" />

In 12-hour mode, day period is a real button. It works with click, touch, arrow keys, and direct A or P input.

Granularity

granularity renders through the requested smallest unit. Omitted minutes or seconds are stored as zero when a complete value is committed.

<TimeField v-model="hour" granularity="hour" />
<TimeField v-model="minute" granularity="minute" />
<TimeField v-model="precise" granularity="second" />

Step and snapping

Step values control keyboard increments for each segment. stepSnapping also rounds complete typed or pasted values to the nearest combined interval.

<TimeField
  v-model="time"
  :step="{ minute: 15 }"
  step-snapping
/>

Constraints and unavailable times

Constraints report native validity after interaction without turning an untouched field red.

<TimeField
  v-model="time"
  :min-value="new Time(9)"
  :max-value="new Time(17)"
  :is-time-unavailable="value => value.hour === 12"
/>

Field and native form

TimeField inherits id, name, required, disabled, descriptions, and validation presentation from Field.

<Field label="Meeting time" name="meeting" required>
  <TimeField v-model="time" />
</Field>

Complete values submit ISO time strings such as 09:30:00. Disabled controls are omitted from FormData.

Zoned values

Passing a ZonedDateTime preserves its date and zone when editing time fields. The zone identifier is visible unless hideTimeZone is enabled.

<TimeField v-model="zonedTime" />
<TimeField v-model="zonedTime" hide-time-zone />

Cancel changes

<TimeField
  v-model="time"
  @value-change="(value, details) => {
    if (value && value.hour < 8) details.cancel()
  }"
/>

Canceled updates restore segment text to the accepted model.

Reactive validation

Native validity tracks controlled values and reactive time constraints without an extra keystroke. Validation feedback remains interaction-driven. Native reset restores the initial time/segments and clears interaction state unless the reset event is canceled.

API Reference

Models

ModelTypeDefaultDescription
v-modelTimeValue | undefinedundefinedAccepted clock value. Existing date and zone data are preserved.
v-model:placeholderTimeValue | undefinedplaceholder or midnightBase value used before a model exists; accepted edits update it.

Props

PropTypeDefaultDescription
idstringField id or generatedId placed on first segment.
namestringField nameNative form name.
localestring"en-US"Segment order, literals, labels, and default hour cycle.
dir"ltr" | "rtl""ltr"Reading direction and horizontal focus movement.
placeholderTimeValuemidnightBase time and value type used before selection.
minValueTimeValueEarliest valid clock time.
maxValueTimeValueLatest valid clock time.
isTimeUnavailable(time) => booleanApplication-level unavailable matcher.
granularity"hour" | "minute" | "second""minute"Smallest rendered and committed unit.
hourCycle12 | 24locale preferenceExplicit hour cycle. Use :hour-cycle="24", not a string attribute.
hideTimeZonebooleanfalseHides zone label for zoned values.
step{ hour?, minute?, second? }each segment 1Segment stepping and optional snap interval.
stepSnappingbooleanfalseRounds complete values to nearest combined step.
requiredbooleanfalseRequires a complete time.
disabledbooleanfalseDisables all segments and native submission.
readOnlybooleanfalseAllows focus but blocks edits.
invalidbooleanfalseForces invalid presentation.
selectOnFocusbooleantrueSelects segment text on focus.
autoAdvancebooleantrueMoves focus after two digits.
ariaLabelstring"Time"Root label when no labelled-by relation exists.
ariaLabelledbystringField label idExplicit label relation.
ariaDescribedbystringField description/error idsExplicit description relation.
uiTimeFieldUiClasses for generated parts.

Emits

EventPayloadDescription
update:modelValueTimeValue | undefinedFires after accepted value changes.
update:placeholderTimeValue | undefinedFires when accepted interaction updates placeholder.
value-change(value, details)Fires before model mutation. details.cancel() rejects it.
value-commit(value, details)Fires after complete input, keyboard, paste, day-period, blur, or clear commit.

Slots

SlotPropsDescription
literalvalueLocale separator content.
day-periodvalue, label, toggleAM/PM control content and event-safe toggle action.
time-zonevalueZone identifier content.

Methods

MethodDescription
focus()Focuses first segment without scrolling page.
clear(event?)Requests an undefined value.
setValue(value, reason, event?)Requests programmatic value change through cancelable contract.

UI Options

KeyPart
rootRoot group.
segmentsLocale-ordered segment container.
segmentEvery numeric spinbutton input.
literalLocale separators.
dayPeriodAM/PM button.
timeZoneZone label.
hiddenInputNative form/validity input.

Styling Hooks

UI keyCSS classData attributes
root.akaza-time-field`data-akaza-state="empty
segments.akaza-time-field-segments
segment.akaza-time-field-segmentdata-akaza-segment, `data-akaza-state="empty
literal.akaza-time-field-literal
dayPeriod.akaza-time-field-day-period`data-akaza-state="am
timeZone.akaza-time-field-time-zone
hiddenInput.akaza-time-field-hidden-input

Direct class applies to root. Use ui.segment, ui.dayPeriod, and other keys for generated inner parts.

Keyboard

KeyBehavior
Number keysReplaces selected segment text. Complete segments update model.
ArrowUp / ArrowDownSteps focused segment, wrapping at boundaries.
PageUp / PageDownSteps focused segment by ten increments.
Home / EndSets segment minimum or maximum.
ArrowLeft / ArrowRightMoves between segments and day period, reversed in RTL.
BackspaceClears text; when empty, moves to previous segment.
A / PSets AM or PM while day period is focused.
PasteDistributes colon- or space-separated time parts.

Each numeric segment uses role="spinbutton" with value bounds. Native inputs and button semantics provide keyboard, mouse, touch, and screen-reader behavior.