Logo

DateInput

DateInput provides a text-based date input interface for selecting single dates or date ranges, with direct keyboard input similar to TimeInput. It offers customizable formatting and validation options without dropdown calendars.
Key features:
  • Date format support: Multiple date formats including MM/dd/yyyy, yyyy-MM-dd, and dd/MM/yyyy
  • Direct input: Keyboard-only date entry with input fields for day, month, and year
  • Input validation: Real-time validation with visual feedback for invalid dates
  • Range support: Single date selection (default) or date range selection
  • Accessibility: Full keyboard navigation and screen reader support

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 to reset the input
When enabled, it displays a clear button that allows users to reset the date input back to its initial value. Enter a date in this app and then click the clear button:
<App>
  <DateInput initialValue="05/25/2024" />
  <DateInput clearable="true" initialValue="05/25/2024" />
</App>
Example: clearable
<App>
  <DateInput initialValue="05/25/2024" />
  <DateInput clearable="true" initialValue="05/25/2024" />
</App>

clearIcon

Icon name for the clear button
<App>
  <DateInput initialValue="05/25/2024" clearable="true" clearIcon="trash" />
</App>
Example: clearIcon
<App>
  <DateInput initialValue="05/25/2024" clearable="true" clearIcon="trash" />
</App>

clearToInitialValue (default: true)

Whether clearing resets to initial value or null
When true, the clear button resets the input to its initial value. When false, it clears the input completely.
<App>
  <DateInput clearable="true" clearToInitialValue="true" initialValue="05/25/2024" />
  <DateInput clearable="true" clearToInitialValue="false" initialValue="05/25/2024" />
</App>
Example: clearToInitialValue
<App>
  <DateInput clearable="true" clearToInitialValue="true" initialValue="05/25/2024" />
  <DateInput clearable="true" clearToInitialValue="false" initialValue="05/25/2024" />
</App>

dateFormat (default: "MM/dd/yyyy")

The format of the date displayed in the input field
Available values: MM/dd/yyyy (default), MM-dd-yyyy, yyyy/MM/dd, yyyy-MM-dd, dd/MM/yyyy, dd-MM-yyyy, yyyyMMdd, MMddyyyy
The dateFormat prop controls how dates are displayed and entered. Different formats change the order and separators of day, month, and year fields.
Regardless of the dateFormat, the year input field always accepts and displays 4-digit years. When entering a 2-digit year, it will be automatically normalized to a 4-digit year.
FormatDescriptionExample
MM/dd/yyyyUS format with slashes05/25/2024
MM-dd-yyyyUS format with dashes05-25-2024
yyyy/MM/ddISO-like format with slashes2024/05/25
yyyy-MM-ddISO format with dashes2024-05-25
dd/MM/yyyyEuropean format with slashes25/05/2024
dd-MM-yyyyEuropean format with dashes25-05-2024
yyyyMMddCompact format without separators20240525
MMddyyyyUS compact format05252024
<App>
  <DateInput dateFormat="MM/dd/yyyy" initialValue="05/25/2024" />
  <DateInput dateFormat="yyyy-MM-dd" initialValue="2024-05-25" />
  <DateInput dateFormat="dd/MM/yyyy" initialValue="25/05/2024" />
  <DateInput dateFormat="yyyyMMdd" initialValue="20240525" />
</App>
Example: dateFormat
<App>
  <DateInput dateFormat="MM/dd/yyyy" initialValue="05/25/2024" />
  <DateInput dateFormat="yyyy-MM-dd" initialValue="2024-05-25" />
  <DateInput dateFormat="dd/MM/yyyy" initialValue="25/05/2024" />
  <DateInput dateFormat="yyyyMMdd" initialValue="20240525" />
</App>

disabledDates

An optional array of dates that are disabled (compatibility with DatePicker, not used in DateInput)

emptyCharacter (default: "-")

Character used to create placeholder text for empty input fields
Character to use as placeholder for empty date values. If longer than 1 character, uses the first character. Defaults to '-'.
<App>
  <DateInput emptyCharacter="." />
  <DateInput emptyCharacter="*" />
  <DateInput emptyCharacter="abc" />
</App>
Example: emptyCharacter
<App>
  <DateInput emptyCharacter="." />
  <DateInput emptyCharacter="*" />
  <DateInput emptyCharacter="abc" />
</App>

enabled (default: true)

This boolean property value indicates whether the component responds to user events (true) or not (false).
<App>
  <DateInput enabled="false" initialValue="05/25/2024" />
</App>  
Example: enabled
<App>
  <DateInput enabled="false" initialValue="05/25/2024" />
</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

The gap between input elements

initialValue

This property sets the component's initial value.
<App>
  <DateInput initialValue="05/25/2024" />
</App>  
Example: initialValue
<App>
  <DateInput initialValue="05/25/2024" />
</App>  

inline (default: true)

Whether to display the date input inline (compatibility with DatePicker, always true for DateInput)

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 DateInput 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 DateInput component's label. If not defined, the label's width will be determined by its content and the available space.

maxValue

The optional end date of the selectable date range. If not defined, the range allows any future dates.

minValue

The optional start date of the selectable date range. If not defined, the range allows any dates in the past.

mode (default: "single")

The mode of the date input (single or range)
Available values: single (default), range
Available values:
ValueDescription
singleSingle date selection (default)
rangeDate range selection

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.
Makes the date input read-only. Users can see the value but cannot modify it.
<App>
  <DateInput readOnly="true" initialValue="05/25/2024" />
</App>
Example: readOnly
<App>
  <DateInput readOnly="true" initialValue="05/25/2024" />
</App>

required (default: false)

Whether the input is required
Marks the date input as required for form validation.
<App>
  <DateInput required="true" />
</App>
Example: required
<App>
  <DateInput required="true" />
</App>

showWeekNumber (default: false)

Whether to show the week number (compatibility with DatePicker, not used in DateInput)

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>
  <DateInput validationStatus="valid" initialValue="05/25/2024" />
  <DateInput validationStatus="warning" initialValue="05/25/2024" />
  <DateInput validationStatus="error" initialValue="05/25/2024" />
</App>
Example: validationStatus
<App>
  <DateInput validationStatus="valid" initialValue="05/25/2024" />
  <DateInput validationStatus="warning" initialValue="05/25/2024" />
  <DateInput validationStatus="error" initialValue="05/25/2024" />
</App>

weekStartsOn (default: 0)

The first day of the week. 0 is Sunday, 1 is Monday, etc. (compatibility with DatePicker, not used in DateInput)
Available values:
ValueDescription
0Sunday (default)
1Monday
2Tuesday
3Wednesday
4Thursday
5Friday
6Saturday

Events

beep

Event triggered when a beep should occur due to invalid input auto-tab prevention
Fired when the user attempts an action that would cause a beep (like entering invalid values).
<App var.beepMessage="">
  <Text value="{beepMessage}" />
  <DateInput 
    onBeep="beepMessage = 'Beep! Invalid input attempted'"
    onDidChange="beepMessage = ''" />
</App>
Example: beep
<App var.beepMessage="">
  <Text value="{beepMessage}" />
  <DateInput 
    onBeep="beepMessage = 'Beep! Invalid input attempted'"
    onDidChange="beepMessage = ''" />
</App>

didChange

This event is triggered when value of DateInput has changed.
Fired when the date value changes. Receives the new date value as a parameter.
The date value changes when the edited input part (day, month, year) loses focus and contains a valid value.
<App var.selectedDate="No date selected">
  <Text value="{selectedDate}" />
  <DateInput 
    dateFormat="yyyy-MM-dd"
    initialValue="2024-05-25" 
    onDidChange="(date) => selectedDate = date" />
</App>
Example: didChange
<App var.selectedDate="No date selected">
  <Text value="{selectedDate}" />
  <DateInput 
    dateFormat="yyyy-MM-dd"
    initialValue="2024-05-25" 
    onDidChange="(date) => selectedDate = date" />
</App>

gotFocus

This event is triggered when the DateInput has received the focus.
Fired when the date input receives focus.
<App var.isFocused="{false}">
  <Text value="{isFocused 
    ? 'DateInput focused' : 'DateInput lost focus'}" 
  />
  <DateInput
    dateFormat="MM/dd/yyyy"
    onGotFocus="isFocused = true"
    onLostFocus="isFocused = false"
    initialValue="05/25/2024"
  />
</App>
Example: gotFocus/lostFocus
<App var.isFocused="{false}">
  <Text value="{isFocused 
    ? 'DateInput focused' : 'DateInput lost focus'}" 
  />
  <DateInput
    dateFormat="MM/dd/yyyy"
    onGotFocus="isFocused = true"
    onLostFocus="isFocused = false"
    initialValue="05/25/2024"
  />
</App>

lostFocus

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

Exposed Methods

focus

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

setValue

This method sets the current value of the DateInput.
Signature: set value(value: any): void
  • value: The new value to set for the date input.
<App>
  <HStack>
    <Button
      label="Set Date to 05/25/2024"
      onClick="picker.setValue('05/25/2024')" />
    <Button
      label="Clear Date"
      onClick="picker.setValue('')" />
  </HStack>
  <DateInput id="picker" />
</App>
Example: setValue
<App>
  <HStack>
    <Button
      label="Set Date to 05/25/2024"
      onClick="picker.setValue('05/25/2024')" />
    <Button
      label="Clear Date"
      onClick="picker.setValue('')" />
  </HStack>
  <DateInput 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:
  • clearButton: The button to clear the date input.
  • day: The day input field.
  • month: The month input field.
  • year: The year input field.

Styling

Theme Variables

VariableDefault Value (Light)Default Value (Dark)
backgroundColor-DateInput--disablednonenone
backgroundColor-DateInput--hovernonenone
backgroundColor-DateInput-defaultnonenone
backgroundColor-DateInput-default--focusnonenone
backgroundColor-DateInput-default--hovernonenone
backgroundColor-DateInput-errornonenone
backgroundColor-DateInput-error--focusnonenone
backgroundColor-DateInput-error--hovernonenone
backgroundColor-DateInput-successnonenone
backgroundColor-DateInput-success--focusnonenone
backgroundColor-DateInput-success--hovernonenone
backgroundColor-DateInput-warningnonenone
backgroundColor-DateInput-warning--focusnonenone
backgroundColor-DateInput-warning--hovernonenone
backgroundColor-input-DateInput-invalidrgba(220, 53, 69, 0.15)rgba(220, 53, 69, 0.15)
border-DateInputnonenone
borderBottom-DateInputnonenone
borderBottomColor-DateInputnonenone
borderBottomStyle-DateInputnonenone
borderBottomWidth-DateInputnonenone
borderColor-DateInputnonenone
borderColor-DateInput--disablednonenone
borderColor-DateInput-defaultnonenone
borderColor-DateInput-default--focusnonenone
borderColor-DateInput-default--hovernonenone
borderColor-DateInput-errornonenone
borderColor-DateInput-error--focusnonenone
borderColor-DateInput-error--hovernonenone
borderColor-DateInput-successnonenone
borderColor-DateInput-success--focusnonenone
borderColor-DateInput-success--hovernonenone
borderColor-DateInput-warningnonenone
borderColor-DateInput-warning--focusnonenone
borderColor-DateInput-warning--hovernonenone
borderEndEndRadius-DateInputnonenone
borderEndStartRadius-DateInputnonenone
borderHorizontal-DateInputnonenone
borderHorizontalColor-DateInputnonenone
borderHorizontalStyle-DateInputnonenone
borderHorizontalWidth-DateInputnonenone
borderLeft-DateInputnonenone
color-DateInputnonenone
borderLeftStyle-DateInputnonenone
borderLeftWidth-DateInputnonenone
borderRadius-button-DateInput$borderRadius$borderRadius
borderRadius-DateInput-defaultnonenone
borderRadius-DateInput-errornonenone
borderRadius-DateInput-successnonenone
borderRadius-DateInput-warningnonenone
borderRadius-input-DateInput$borderRadius$borderRadius
borderRight-DateInputnonenone
color-DateInputnonenone
borderRightStyle-DateInputnonenone
borderRightWidth-DateInputnonenone
borderStartEndRadius-DateInputnonenone
borderStartStartRadius-DateInputnonenone
borderStyle-DateInputnonenone
borderStyle-DateInput-defaultnonenone
borderStyle-DateInput-errornonenone
borderStyle-DateInput-successnonenone
borderStyle-DateInput-warningnonenone
borderTop-DateInputnonenone
borderTopColor-DateInputnonenone
borderTopStyle-DateInputnonenone
borderTopWidth-DateInputnonenone
borderHorizontal-DateInputnonenone
borderVerticalColor-DateInputnonenone
borderVerticalStyle-DateInputnonenone
borderVerticalWidth-DateInputnonenone
borderWidth-DateInputnonenone
borderWidth-DateInput-defaultnonenone
borderWidth-DateInput-errornonenone
borderWidth-DateInput-successnonenone
borderWidth-DateInput-warningnonenone
boxShadow-DateInput-defaultnonenone
boxShadow-DateInput-default--focusnonenone
boxShadow-DateInput-default--hovernonenone
boxShadow-DateInput-errornonenone
boxShadow-DateInput-error--focusnonenone
boxShadow-DateInput-error--hovernonenone
boxShadow-DateInput-successnonenone
boxShadow-DateInput-success--focusnonenone
boxShadow-DateInput-success--hovernonenone
boxShadow-DateInput-warningnonenone
boxShadow-DateInput-warning--focusnonenone
boxShadow-DateInput-warning--hovernonenone
color-adornment-DateInput-defaultnonenone
color-adornment-DateInput-errornonenone
color-adornment-DateInput-successnonenone
color-adornment-DateInput-warningnonenone
color-divider-DateInput$textColor-secondary$textColor-secondary
disabledColor-button-DateInput$textColor-disabled$textColor-disabled
fontSize-ampm-DateInputinheritinherit
fontSize-input-DateInputinheritinherit
gap-adornment-DateInputnonenone
hoverColor-button-DateInput$color-surface-800$color-surface-800
margin-input-DateInputnonenone
minWidth-ampm-DateInput2em2em
minWidth-input-DateInput0.54em0.54em
opacity-DateInput--disablednonenone
outlineColor-button-DateInput--focused$color-accent-500$color-accent-500
outlineColor-DateInput-default--focusnonenone
outlineColor-DateInput-error--focusnonenone
outlineColor-DateInput-success--focusnonenone
outlineColor-DateInput-warning--focusnonenone
outlineOffset-button-DateInput--focused2px2px
outlineOffset-DateInput-default--focusnonenone
outlineOffset-DateInput-error--focusnonenone
outlineOffset-DateInput-success--focusnonenone
outlineOffset-DateInput-warning--focusnonenone
outlineStyle-DateInput-default--focusnonenone
outlineStyle-DateInput-error--focusnonenone
outlineStyle-DateInput-success--focusnonenone
outlineStyle-DateInput-warning--focusnonenone
outlineWidth-button-DateInput--focused2px2px
outlineWidth-DateInput-default--focusnonenone
outlineWidth-DateInput-error--focusnonenone
outlineWidth-DateInput-success--focusnonenone
outlineWidth-DateInput-warning--focusnonenone
padding-button-DateInput4px 6px4px 6px
padding-DateInputnonenone
padding-DateInput-defaultnonenone
padding-DateInput-errornonenone
padding-DateInput-successnonenone
padding-DateInput-warningnonenone
padding-input-DateInput0 2px0 2px
paddingBottom-DateInputnonenone
paddingHorizontal-DateInputnonenone
paddingLeft-DateInputnonenone
paddingRight-DateInputnonenone
paddingTop-DateInputnonenone
paddingVertical-DateInputnonenone
spacing-divider-DateInput1px 01px 0
textAlign-input-DateInputcentercenter
textColor-DateInput--disablednonenone
textColor-DateInput-defaultnonenone
textColor-DateInput-default--focusnonenone
textColor-DateInput-default--hovernonenone
textColor-DateInput-errornonenone
textColor-DateInput-error--focusnonenone
textColor-DateInput-error--hovernonenone
textColor-DateInput-successnonenone
textColor-DateInput-success--focusnonenone
textColor-DateInput-success--hovernonenone
textColor-DateInput-warningnonenone
textColor-DateInput-warning--focusnonenone
textColor-DateInput-warning--hovernonenone
transition-background-DateInputnonenone
width-input-DateInput1.8em1.8em
This site is an XMLUI™ app.