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:
| Behavior | Properties |
|---|---|
| Animation | animation, animationOptions |
| Bookmark | bookmark, bookmarkLevel, bookmarkTitle, bookmarkOmitFromToc |
| Form Binding | bindTo, initialValue, noSubmit |
| Component Label | label, labelPosition, labelWidth, labelBreak, required, enabled, shrinkToLabel, style, readOnly |
| Publish/Subscribe | subscribeToTopic |
| Tooltip | tooltip, tooltipMarkdown, tooltipOptions |
| Validation | bindTo, required, minLength, maxLength, lengthInvalidMessage, lengthInvalidSeverity, minValue, maxValue, rangeInvalidMessage, rangeInvalidSeverity, pattern, patternInvalidMessage, patternInvalidSeverity, regex, regexInvalidMessage, regexInvalidSeverity, validationMode, verboseValidationFeedback |
| Styling Variant | variant |
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><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><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><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.
| Format | Description | Example |
|---|---|---|
MM/dd/yyyy | US format with slashes | 05/25/2024 |
MM-dd-yyyy | US format with dashes | 05-25-2024 |
yyyy/MM/dd | ISO-like format with slashes | 2024/05/25 |
yyyy-MM-dd | ISO format with dashes | 2024-05-25 |
dd/MM/yyyy | European format with slashes | 25/05/2024 |
dd-MM-yyyy | European format with dashes | 25-05-2024 |
yyyyMMdd | Compact format without separators | 20240525 |
MMddyyyy | US compact format | 05252024 |
<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><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><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> <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> <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:
| Value | Description |
|---|---|
single | Single date selection (default) |
range | Date 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><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><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:
| Value | Description |
|---|---|
valid | Visual indicator for an input that is accepted |
warning | Visual indicator for an input that produced a warning |
error | Visual indicator for an input that produced an error |
| Value | Description |
|---|---|
valid | Visual indicator for an input that is accepted |
warning | Visual indicator for an input that produced a warning |
error | Visual 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><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:
| Value | Description |
|---|---|
0 | Sunday (default) |
1 | Monday |
2 | Tuesday |
3 | Wednesday |
4 | Thursday |
5 | Friday |
6 | Saturday |
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><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><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><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
| Variable | Default Value (Light) | Default Value (Dark) |
|---|---|---|
| backgroundColor-DateInput | $backgroundColor | $backgroundColor |
| backgroundColor-DateInput--default | none | none |
| backgroundColor-DateInput--default--focus | none | none |
| backgroundColor-DateInput--default--hover | none | none |
| backgroundColor-DateInput--disabled | none | none |
| backgroundColor-DateInput--error | none | none |
| backgroundColor-DateInput--error--focus | none | none |
| backgroundColor-DateInput--error--hover | none | none |
| backgroundColor-DateInput--hover | none | none |
| backgroundColor-DateInput--success | none | none |
| backgroundColor-DateInput--success--focus | none | none |
| backgroundColor-DateInput--success--hover | none | none |
| backgroundColor-DateInput--warning | none | none |
| backgroundColor-DateInput--warning--focus | none | none |
| backgroundColor-DateInput--warning--hover | none | none |
| backgroundColor-input-DateInput-invalid | rgba(220, 53, 69, 0.15) | rgba(220, 53, 69, 0.15) |
| border-DateInput | none | none |
| borderBottom-DateInput | none | none |
| borderBottomColor-DateInput | none | none |
| borderBottomStyle-DateInput | none | none |
| borderBottomWidth-DateInput | none | none |
| borderColor-DateInput | none | none |
| borderColor-DateInput--default | none | none |
| borderColor-DateInput--default--focus | none | none |
| borderColor-DateInput--default--hover | none | none |
| borderColor-DateInput--disabled | none | none |
| borderColor-DateInput--error | none | none |
| borderColor-DateInput--error--focus | none | none |
| borderColor-DateInput--error--hover | none | none |
| borderColor-DateInput--success | none | none |
| borderColor-DateInput--success--focus | none | none |
| borderColor-DateInput--success--hover | none | none |
| borderColor-DateInput--warning | none | none |
| borderColor-DateInput--warning--focus | none | none |
| borderColor-DateInput--warning--hover | none | none |
| borderEndEndRadius-DateInput | none | none |
| borderEndStartRadius-DateInput | none | none |
| borderHorizontal-DateInput | none | none |
| borderHorizontalColor-DateInput | none | none |
| borderHorizontalStyle-DateInput | none | none |
| borderHorizontalWidth-DateInput | none | none |
| borderLeft-DateInput | none | none |
| borderLeftColor-DateInput | none | none |
| borderLeftStyle-DateInput | none | none |
| borderLeftWidth-DateInput | none | none |
| borderRadius-button-DateInput | $borderRadius | $borderRadius |
| borderRadius-DateInput--default | none | none |
| borderRadius-DateInput--error | none | none |
| borderRadius-DateInput--success | none | none |
| borderRadius-DateInput--warning | none | none |
| borderRadius-input-DateInput | $borderRadius | $borderRadius |
| borderRight-DateInput | none | none |
| borderRightColor-DateInput | none | none |
| borderRightStyle-DateInput | none | none |
| borderRightWidth-DateInput | none | none |
| borderStartEndRadius-DateInput | none | none |
| borderStartStartRadius-DateInput | none | none |
| borderStyle-DateInput | none | none |
| borderStyle-DateInput--default | none | none |
| borderStyle-DateInput--error | none | none |
| borderStyle-DateInput--success | none | none |
| borderStyle-DateInput--warning | none | none |
| borderTop-DateInput | none | none |
| borderTopColor-DateInput | none | none |
| borderTopStyle-DateInput | none | none |
| borderTopWidth-DateInput | none | none |
| borderVertical-DateInput | none | none |
| borderVerticalColor-DateInput | none | none |
| borderVerticalStyle-DateInput | none | none |
| borderVerticalWidth-DateInput | none | none |
| borderWidth-DateInput | none | none |
| borderWidth-DateInput--default | none | none |
| borderWidth-DateInput--error | none | none |
| borderWidth-DateInput--success | none | none |
| borderWidth-DateInput--warning | none | none |
| boxShadow-DateInput--default | none | none |
| boxShadow-DateInput--default--focus | none | none |
| boxShadow-DateInput--default--hover | none | none |
| boxShadow-DateInput--error | none | none |
| boxShadow-DateInput--error--focus | none | none |
| boxShadow-DateInput--error--hover | none | none |
| boxShadow-DateInput--success | none | none |
| boxShadow-DateInput--success--focus | none | none |
| boxShadow-DateInput--success--hover | none | none |
| boxShadow-DateInput--warning | none | none |
| boxShadow-DateInput--warning--focus | none | none |
| boxShadow-DateInput--warning--hover | none | none |
| color-adornment-DateInput--default | none | none |
| color-adornment-DateInput--error | none | none |
| color-adornment-DateInput--success | none | none |
| color-adornment-DateInput--warning | none | none |
| color-divider-DateInput | $textColor-secondary | $textColor-secondary |
| disabledColor-button-DateInput | $textColor-disabled | $textColor-disabled |
| fontSize-DateInput--default | none | none |
| fontSize-DateInput--error | none | none |
| fontSize-DateInput--success | none | none |
| fontSize-DateInput--warning | none | none |
| fontSize-input-DateInput | none | none |
| fontSize-input-DateInput--default | none | none |
| fontSize-input-DateInput--error | none | none |
| fontSize-input-DateInput--success | none | none |
| fontSize-input-DateInput--warning | none | none |
| gap-adornment-DateInput | none | none |
| hoverColor-button-DateInput | $color-surface-800 | $color-surface-800 |
| margin-input-DateInput | none | none |
| minWidth-input-DateInput | 0.54em | 0.54em |
| opacity-DateInput--disabled | none | none |
| outlineColor-button-DateInput--focused | $color-accent-500 | $color-accent-500 |
| outlineColor-DateInput--default--focus | none | none |
| outlineColor-DateInput--error--focus | none | none |
| outlineColor-DateInput--success--focus | none | none |
| outlineColor-DateInput--warning--focus | none | none |
| outlineOffset-button-DateInput--focused | 2px | 2px |
| outlineOffset-DateInput--default--focus | none | none |
| outlineOffset-DateInput--error--focus | none | none |
| outlineOffset-DateInput--success--focus | none | none |
| outlineOffset-DateInput--warning--focus | none | none |
| outlineStyle-DateInput--default--focus | none | none |
| outlineStyle-DateInput--error--focus | none | none |
| outlineStyle-DateInput--success--focus | none | none |
| outlineStyle-DateInput--warning--focus | none | none |
| outlineWidth-button-DateInput--focused | 2px | 2px |
| outlineWidth-DateInput--default--focus | none | none |
| outlineWidth-DateInput--error--focus | none | none |
| outlineWidth-DateInput--success--focus | none | none |
| outlineWidth-DateInput--warning--focus | none | none |
| padding-button-DateInput | 4px 6px | 4px 6px |
| padding-DateInput | none | none |
| padding-input-DateInput | 0 2px | 0 2px |
| paddingBottom-DateInput | none | none |
| paddingHorizontal-DateInput | $space-2 | $space-2 |
| paddingLeft-DateInput | none | none |
| paddingRight-DateInput | none | none |
| paddingTop-DateInput | none | none |
| paddingVertical-DateInput | $space-2 | $space-2 |
| spacing-divider-DateInput | 1px 0 | 1px 0 |
| textAlign-input-DateInput | center | center |
| textColor-DateInput--default | none | none |
| textColor-DateInput--default--focus | none | none |
| textColor-DateInput--default--hover | none | none |
| textColor-DateInput--disabled | none | none |
| textColor-DateInput--error | none | none |
| textColor-DateInput--error--focus | none | none |
| textColor-DateInput--error--hover | none | none |
| textColor-DateInput--success | none | none |
| textColor-DateInput--success--focus | none | none |
| textColor-DateInput--success--hover | none | none |
| textColor-DateInput--warning | none | none |
| textColor-DateInput--warning--focus | none | none |
| textColor-DateInput--warning--hover | none | none |
| transition-background-DateInput | none | none |
| width-input-DateInput | 1.8em | 1.8em |