Logo

TimeInput

TimeInput provides time input with support for 12-hour and 24-hour formats and configurable precision for hours, minutes, and seconds.
Key features:
  • Time format support: 12-hour and 24-hour formats with customizable display
  • Precision control: Configure precision for hours, minutes, and seconds
  • Input validation: Real-time validation with visual feedback for invalid times
  • Accessibility: Full keyboard navigation and screen reader support
  • Localization: Automatic AM/PM labels based on user locale

Properties

autoFocus (default: false)

If this property is set to true, the component gets the focus automatically when displayed.

clearable (default: false)

Whether to show a clear button that allows clearing the selected time
When enabled, it displays a clear button that allows users to reset the time picker back to its initial value. Change the time value in this app and then click the clear button:
<App>
  <TimeInput initialValue="11:30" />
  <TimeInput clearable="true" initialValue="10:20" />
</App>
Example: clearable
<App>
  <TimeInput initialValue="11:30" />
  <TimeInput clearable="true" initialValue="10:20" />
</App>

clearIcon

The icon to display in the clear button.
<App>
  <TimeInput initialValue="11:30" clearIcon="trash" />
</App>
Example: clearIcon
<App>
  <TimeInput initialValue="11:30" clearIcon="trash" />
</App>

clearToInitialValue (default: true)

Whether the clear button resets the time input to its initial value

emptyCharacter (default: "-")

Character to use as placeholder for empty time values. If longer than 1 character, uses the first character. Defaults to '-'
Character to use as placeholder for empty time values. If longer than 1 character, uses the first character. Defaults to '-'.
<App>
  <TimeInput emptyCharacter="." />
  <TimeInput emptyCharacter="*" />
  <TimeInput emptyCharacter="abc" />
</App>
Example: emptyCharacter
<App>
  <TimeInput emptyCharacter="." />
  <TimeInput emptyCharacter="*" />
  <TimeInput emptyCharacter="abc" />
</App>

enabled (default: true)

This boolean property value indicates whether the component responds to user events (true) or not (false).
<App>
  <TimeInput enabled="false" initialValue="14:30" />
</App>  
Example: enabled
<App>
  <TimeInput enabled="false" initialValue="14:30" />
</App>  

endIcon

This property sets an optional icon to appear on the end (right side when the left-to-right direction is set) of the input.

endText

This property sets an optional text to appear on the end (right side when the left-to-right direction is set) of the input.

gap

This property defines the gap between the adornments and the input area. If not set, the gap declared by the current theme is used.

hour24 (default: true)

Whether to use 24-hour format (true) or 12-hour format with AM/PM (false)

initialValue

This property sets the component's initial value.
<App>
  <TimeInput initialValue="14:30:15" />
</App>  
Example: initialValue
<App>
  <TimeInput initialValue="14:30:15" />
</App>  

label

This property sets the label of the component. If not set, the component will not display a label.

labelBreak (default: true)

This boolean value indicates whether the TimeInput label can be split into multiple lines if it would overflow the available label width.

labelPosition (default: "top")

Places the label at the given position of the component.
Available values:
ValueDescription
startThe left side of the input (left-to-right) or the right side of the input (right-to-left)
endThe right side of the input (left-to-right) or the left side of the input (right-to-left)
topThe top of the input (default)
bottomThe bottom of the input

labelWidth

This property sets the width of the TimeInput component's label. If not defined, the label's width will be determined by its content and the available space.

maxTime

Maximum time that the user can select

minTime

Minimum time that the user can select

mute (default: false)

Whether to mute the beep sound while still firing the beep event
When true, prevents audible beeps but still fires the beep event for programmatic handling.

readOnly (default: false)

Set this property to true to disallow changing the component value.

required (default: false)

Whether the time input should be required
Marks the time input as required for form validation.
<App>
  <TimeInput required="true" />
</App>
Example: required
<App>
  <TimeInput required="true" />
</App>

seconds (default: false)

Whether to show and allow input of seconds

startIcon

This property sets an optional icon to appear at the start (left side when the left-to-right direction is set) of the input.

startText

This property sets an optional text to appear at the start (left side when the left-to-right direction is set) of the input.

validationStatus (default: "none")

This property allows you to set the validation status of the input component.
Available values:
ValueDescription
validVisual indicator for an input that is accepted
warningVisual indicator for an input that produced a warning
errorVisual indicator for an input that produced an error
ValueDescription
validVisual indicator for an input that is accepted
warningVisual indicator for an input that produced a warning
errorVisual indicator for an input that produced an error
<App>
  <TimeInput validationStatus="valid" initialValue="11:30" />
  <TimeInput validationStatus="warning" initialValue="11:30" />
  <TimeInput validationStatus="error" initialValue="11:30" />
</App>
Example: validationStatus
<App>
  <TimeInput validationStatus="valid" initialValue="11:30" />
  <TimeInput validationStatus="warning" initialValue="11:30" />
  <TimeInput validationStatus="error" initialValue="11:30" />
</App>

Events

beep

Fired when a beep sound is played due to invalid input, allowing custom feedback implementations

didChange

This event is triggered when value of TimeInput has changed.
Fired when the time value changes. Receives the new time value as a parameter.
The time value changes when the edited input part (hour, minute, second) loses focus or the AM/PM selectro changes.
<App var.selectedTime="No time selected">
  <Text value="{selectedTime}" />
  <TimeInput 
    format="h:m:s a"
    initialValue="07:30:05" 
    onDidChange="(time) => selectedTime = time" />
</App>
Example: didChange
<App var.selectedTime="No time selected">
  <Text value="{selectedTime}" />
  <TimeInput 
    format="h:m:s a"
    initialValue="07:30:05" 
    onDidChange="(time) => selectedTime = time" />
</App>

gotFocus

This event is triggered when the TimeInput has received the focus.
Fired when the time picker receives focus.
<App var.isFocused="{false}">
  <Text value="{isFocused 
    ? 'TimeInput focused' : 'TimeInput lost focus'}" 
  />
  <TimeInput
    format="HH:mm:ss a"
    onGotFocus="isFocused = true"
    onLostFocus="isFocused = false"
    initialValue="14:30"
  />
</App>
Example: gotFocus/lostFocus
<App var.isFocused="{false}">
  <Text value="{isFocused 
    ? 'TimeInput focused' : 'TimeInput lost focus'}" 
  />
  <TimeInput
    format="HH:mm:ss a"
    onGotFocus="isFocused = true"
    onLostFocus="isFocused = false"
    initialValue="14:30"
  />
</App>

invalidTime

Fired when the user enters an invalid time
Fired when the user enters an invalid time value.
<App var.errorMessage="">
  <Text value="{errorMessage}" />
  <TimeInput 
    onInvalidTime="(error) => errorMessage = 'Invalid time entered'"
    onDidChange="errorMessage = ''" />
</App>
Example: invalidTime
<App var.errorMessage="">
  <Text value="{errorMessage}" />
  <TimeInput 
    onInvalidTime="(error) => errorMessage = 'Invalid time entered'"
    onDidChange="errorMessage = ''" />
</App>

lostFocus

This event is triggered when the TimeInput has lost the focus.

Exposed Methods

focus

Focus the TimeInput component.
Signature: focus(): void

setValue

This method sets the current value of the TimeInput.
Signature: set value(value: any): void
  • value: The new time value to set for the time picker.
<App>
  <HStack>
    <Button
      label="Set Time to 14:30"
      onClick="picker.setValue('14:30')" />
    <Button
      label="Remove Time"
      onClick="picker.setValue('')" />
  </HStack>
  <TimeInput id="picker" />
</App>
Example: setValue
<App>
  <HStack>
    <Button
      label="Set Time to 14:30"
      onClick="picker.setValue('14:30')" />
    <Button
      label="Remove Time"
      onClick="picker.setValue('')" />
  </HStack>
  <TimeInput id="picker" />
</App>

value

You can query the component's value. If no value is set, it will retrieve undefined.
Signature: get value(): any

Parts

The component has some parts that can be styled through layout properties and theme variables separately:
  • ampm: The AM/PM indicator.
  • clearButton: The button to clear the time input.
  • hour: The hour input field.
  • minute: The minute input field.
  • second: The second input field.

Styling

Theme Variables

VariableDefault Value (Light)Default Value (Dark)
backgroundColor-input-TimeInput-invalidrgba(220, 53, 69, 0.15)rgba(220, 53, 69, 0.15)
backgroundColor-item-TimeInput--activenonenone
backgroundColor-item-TimeInput--hovernonenone
backgroundColor-menu-TimeInputnonenone
backgroundColor-TimeInput--disablednonenone
backgroundColor-TimeInput--hovernonenone
backgroundColor-TimeInput-defaultnonenone
backgroundColor-TimeInput-default--focusnonenone
backgroundColor-TimeInput-default--hovernonenone
backgroundColor-TimeInput-errornonenone
backgroundColor-TimeInput-error--focusnonenone
backgroundColor-TimeInput-error--hovernonenone
backgroundColor-TimeInput-successnonenone
backgroundColor-TimeInput-success--focusnonenone
backgroundColor-TimeInput-success--hovernonenone
backgroundColor-TimeInput-warningnonenone
backgroundColor-TimeInput-warning--focusnonenone
backgroundColor-TimeInput-warning--hovernonenone
borderColor-menu-TimeInputnonenone
borderColor-TimeInput--disablednonenone
borderColor-TimeInput-defaultnonenone
borderColor-TimeInput-default--focusnonenone
borderColor-TimeInput-default--hovernonenone
borderColor-TimeInput-errornonenone
borderColor-TimeInput-error--focusnonenone
borderColor-TimeInput-error--hovernonenone
borderColor-TimeInput-successnonenone
borderColor-TimeInput-success--focusnonenone
borderColor-TimeInput-success--hovernonenone
borderColor-TimeInput-warningnonenone
borderColor-TimeInput-warning--focusnonenone
borderColor-TimeInput-warning--hovernonenone
borderRadius-button-TimeInput$borderRadius$borderRadius
borderRadius-input-TimeInput$borderRadius$borderRadius
borderRadius-menu-TimeInputnonenone
borderRadius-TimeInput-defaultnonenone
borderRadius-TimeInput-errornonenone
borderRadius-TimeInput-successnonenone
borderRadius-TimeInput-warningnonenone
borderStyle-TimeInput-defaultnonenone
borderStyle-TimeInput-errornonenone
borderStyle-TimeInput-successnonenone
borderStyle-TimeInput-warningnonenone
borderWidth-TimeInput-defaultnonenone
borderWidth-TimeInput-errornonenone
borderWidth-TimeInput-successnonenone
borderWidth-TimeInput-warningnonenone
boxShadow-menu-TimeInputnonenone
boxShadow-TimeInput-defaultnonenone
boxShadow-TimeInput-default--focusnonenone
boxShadow-TimeInput-default--hovernonenone
boxShadow-TimeInput-errornonenone
boxShadow-TimeInput-error--focusnonenone
boxShadow-TimeInput-error--hovernonenone
boxShadow-TimeInput-successnonenone
boxShadow-TimeInput-success--focusnonenone
boxShadow-TimeInput-success--hovernonenone
boxShadow-TimeInput-warningnonenone
boxShadow-TimeInput-warning--focusnonenone
boxShadow-TimeInput-warning--hovernonenone
color-adornment-TimeInput-defaultnonenone
color-adornment-TimeInput-errornonenone
color-adornment-TimeInput-successnonenone
color-adornment-TimeInput-warningnonenone
color-divider-TimeInput$textColor-secondary$textColor-secondary
disabledColor-button-TimeInput$textColor-disabled$textColor-disabled
fontSize-ampm-TimeInputinheritinherit
fontSize-input-TimeInputinheritinherit
gap-adornment-TimeInputnonenone
hoverColor-button-TimeInput$color-surface-800$color-surface-800
margin-icon-TimeInputnonenone
margin-input-TimeInputnonenone
maxHeight-menu-TimeInputnonenone
minWidth-ampm-TimeInput2em2em
minWidth-input-TimeInput0.54em0.54em
opacity-item-TimeInput--disablednonenone
opacity-TimeInput--disablednonenone
outlineColor-ampm-TimeInput--focusednonenone
outlineColor-button-TimeInput--focused$color-accent-500$color-accent-500
outlineColor-TimeInput-default--focusnonenone
outlineColor-TimeInput-error--focusnonenone
outlineColor-TimeInput-success--focusnonenone
outlineColor-TimeInput-warning--focusnonenone
outlineOffset-ampm-TimeInput--focusednonenone
outlineOffset-button-TimeInput--focused2px2px
outlineOffset-TimeInput-default--focusnonenone
outlineOffset-TimeInput-error--focusnonenone
outlineOffset-TimeInput-success--focusnonenone
outlineOffset-TimeInput-warning--focusnonenone
outlineStyle-TimeInput-default--focusnonenone
outlineStyle-TimeInput-error--focusnonenone
outlineStyle-TimeInput-success--focusnonenone
outlineStyle-TimeInput-warning--focusnonenone
outlineWidth-ampm-TimeInput--focusednonenone
outlineWidth-button-TimeInput--focused2px2px
outlineWidth-TimeInput-default--focusnonenone
outlineWidth-TimeInput-error--focusnonenone
outlineWidth-TimeInput-success--focusnonenone
outlineWidth-TimeInput-warning--focusnonenone
padding-button-TimeInput4px 6px4px 6px
padding-input-TimeInput0 2px0 2px
padding-item-TimeInputnonenone
padding-TimeInput-defaultnonenone
padding-TimeInput-errornonenone
padding-TimeInput-successnonenone
padding-TimeInput-warningnonenone
spacing-divider-TimeInput1px 01px 0
textAlign-input-TimeInputcentercenter
textColor-TimeInput--disablednonenone
textColor-TimeInput-defaultnonenone
textColor-TimeInput-default--focusnonenone
textColor-TimeInput-default--hovernonenone
textColor-TimeInput-errornonenone
textColor-TimeInput-error--focusnonenone
textColor-TimeInput-error--hovernonenone
textColor-TimeInput-successnonenone
textColor-TimeInput-success--focusnonenone
textColor-TimeInput-success--hovernonenone
textColor-TimeInput-warningnonenone
textColor-TimeInput-warning--focusnonenone
textColor-TimeInput-warning--hovernonenone
transition-background-TimeInputnonenone
width-input-TimeInput1.8em1.8em
This site is an XMLUI™ app.