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

Behaviors

This component supports the following behaviors:

BehaviorProperties
Animationanimation, animationOptions
Bookmarkbookmark, bookmarkLevel, bookmarkTitle, bookmarkOmitFromToc
Form BindingbindTo, initialValue, noSubmit
Component Labellabel, labelPosition, labelWidth, labelBreak, required, enabled, shrinkToLabel, style, readOnly
Publish/SubscribesubscribeToTopic
Tooltiptooltip, tooltipMarkdown, tooltipOptions
ValidationbindTo, required, minLength, maxLength, lengthInvalidMessage, lengthInvalidSeverity, minValue, maxValue, rangeInvalidMessage, rangeInvalidSeverity, pattern, patternInvalidMessage, patternInvalidSeverity, regex, regexInvalidMessage, regexInvalidSeverity, validationMode, verboseValidationFeedback
Styling Variantvariant

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 clear the date input. 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: false

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)

invalidMessages

The invalid messages to display for the input component.

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

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.

validationIconError

Icon to display for error state when concise validation summary is enabled.

validationIconSuccess

Icon to display for valid state when concise validation summary is enabled.

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>

verboseValidationFeedback

Enables a concise validation summary (icon) in input components.

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

didChange

This event is triggered when value of DateInput has changed.

Signature: didChange(newValue: any): void

  • newValue: The new value of the component.

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.

Signature: gotFocus(): void

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.

Signature: lostFocus(): void

Exposed Methods

focus

Focus the DateInput component.

Signature: focus(): void

isoValue

Get the current date value formatted in ISO standard (YYYY-MM-DD) format, suitable for JSON serialization.

Signature: isoValue(): string | null

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$backgroundColor$backgroundColor
backgroundColor-DateInput--defaultnonenone
backgroundColor-DateInput--default--focusnonenone
backgroundColor-DateInput--default--hovernonenone
backgroundColor-DateInput--disablednonenone
backgroundColor-DateInput--errornonenone
backgroundColor-DateInput--error--focusnonenone
backgroundColor-DateInput--error--hovernonenone
backgroundColor-DateInput--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--defaultnonenone
borderColor-DateInput--default--focusnonenone
borderColor-DateInput--default--hovernonenone
borderColor-DateInput--disablednonenone
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
borderLeftColor-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
borderRightColor-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
borderVertical-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-DateInput--defaultnonenone
fontSize-DateInput--errornonenone
fontSize-DateInput--successnonenone
fontSize-DateInput--warningnonenone
fontSize-input-DateInputnonenone
fontSize-input-DateInput--defaultnonenone
fontSize-input-DateInput--errornonenone
fontSize-input-DateInput--successnonenone
fontSize-input-DateInput--warningnonenone
gap-adornment-DateInputnonenone
hoverColor-button-DateInput$color-surface-800$color-surface-800
margin-input-DateInputnonenone
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-input-DateInput0 2px0 2px
paddingBottom-DateInputnonenone
paddingHorizontal-DateInput$space-2$space-2
paddingLeft-DateInputnonenone
paddingRight-DateInputnonenone
paddingTop-DateInputnonenone
paddingVertical-DateInput$space-2$space-2
spacing-divider-DateInput1px 01px 0
textAlign-input-DateInputcentercenter
textColor-DateInput--defaultnonenone
textColor-DateInput--default--focusnonenone
textColor-DateInput--default--hovernonenone
textColor-DateInput--disablednonenone
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