Date Input
Date inputs let users enter a date through a segmented field or select one visually from a popup calendar. They support locale-aware segment order, min and max constraints, and form validation.
-
Pro Components -
Responsive Layout Tools -
Ever-Growing Pattern Library -
Unlimited Hosted Projects -
Pre-Built Pro Themes -
Pro Theme Builder -
Pro Color Tools -
Official Figma Design Kit Newer additions to Web Awesome, like <wa-toast>, aren't included in the currently available kit, but a new version is in the works.
Track its progress on GitHub. -
WA Pro Perpetual License -
Actual Human™ Support
Already have Pro? Log in
Date Input is the form-associated counterpart to <wa-date-picker>. It renders a segmented input with discrete month, day, and year spinbutton segments in the user's locale order, alongside a popup calendar for visual selection. The segment order, separators, and submitted ISO value all derive from the page's locale.
Use the arrow keys to step through values, type digits to fill segments (focus auto-advances when the segment can accept no further digit), and use Alt+Down Arrow to open the popup calendar. The entire field is one tab stop.
Form Submission
The hidden form value is canonical ISO 8601, regardless of the user's locale:
| Mode | Form value | Notes |
|---|---|---|
| Single (default) | YYYY-MM-DD |
e.g. 2026-01-23 |
| Range | YYYY-MM-DD/YYYY-MM-DD |
Start and end, slash-separated |
| Partial input | (empty) | The value stays empty until the input parses |
The example below renders a working form. Submit it (or change the date) and watch the console. The date input submits its value just like a native <input>, regardless of how the user typed or what locale they used.
Examples
Initial Value
Set the value attribute to an ISO date to pre-populate the input.
Label
Use the label attribute to give the date input an accessible label. For labels that contain HTML, use the label slot instead.
Hint
Add descriptive hint to a date input with the hint attribute. For hints that contain HTML, use the hint slot instead.
Start & End Decorations
Use the start and end slots to add presentational elements like <wa-icon> inside the input.
Clearable
Add the with-clear attribute to let users wipe their selection in a single click. The clear button only appears once a value is set.
Min & Max
Use min and max to constrain the selectable range. Dates outside the range render as disabled in the popup, can't be selected by clicking, and are skipped by keyboard navigation.
Disabling Past & Future
Use disable-past or disable-future to block all dates strictly before or after today, without having to recalculate min/max every day.
Disabling Specific Dates & Days of the Week
Use disabled-days-of-week to block recurring weekdays (e.g., weekends), and disabled-dates to block specific calendar dates such as holidays.
Date Range
Use mode="range" to let users select a start and end date. The calendar opens in range mode automatically.
Range Length Constraints
In range mode, use min-range and max-range to require the selection to fall within a specific number of days.
Size
Use the size attribute to match the date input to surrounding form controls.
Appearance
Use the appearance attribute to switch between the default outlined input, a filled background, or a filled input with an outlined border.
Pill
Use the pill attribute to give the input fully rounded edges.
Disabled
Use the disabled attribute to disable the date input entirely. Disabled date inputs don't accept input, are skipped during tabbing, and don't submit a value with the form.
Readonly
Use the readonly attribute to make the date input non-editable while still allowing it to be focused and to submit its value with the form. The popup still opens for browsing.
Localization
Set lang on the input (or anywhere up the tree) to localize the input format and popup calendar.
Customizing the Popup
Use placement to anchor the popup relative to the input and distance to control the gap between them.
Conditionally Disabling Dates
Set the isDateDisabled property to a function that returns true for any date that should be unselectable. This runs in addition to the declarative min, max, disabled-dates, and disabled-days-of-week rules.
Custom Day Content
Forward the dayContent callback to render anything inside individual day cells (badges, dots, availability counts).
Custom Per-Day Slots
Set slot="day-YYYY-MM-DD" on a child element to override that specific day's content.
Custom Navigation Icons
Use the previous-icon and next-icon slots to replace the calendar's default paging arrows.
Custom Footer
The footer slot is forwarded to the popup calendar.
Programmatic API
Set or read the value, listen for changes, and open or close the popup from JavaScript.
<wa-date-input id="dp" label="Programmatic"></wa-date-input> <script> const dp = document.getElementById('dp'); // Set a value dp.value = '2026-01-23'; // Or set with a Date dp.value = new Date(2026, 0, 23); // Read parsed value console.log(dp.valueAsDate); // Open/close await dp.show(); await dp.hide(); // Listen for changes dp.addEventListener('change', e => console.log('value:', e.target.value)); dp.addEventListener('wa-after-show', () => console.log('popup opened')); </script>
API
Importing
If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.
Import this component directly from the CDN:
import 'https://ka-f.webawesome.com/[email protected]/components/date-input/date-input.js';
After installing Web Awesome via npm, import this component:
import '@awesome.me/webawesome/dist/components/date-input/date-input.js';
If you're self-hosting Web Awesome, import this component from your server:
import './webawesome/dist/components/date-input/date-input.js';
To import this component for React 18 or below, use the following code:
import WaDateInput from '@awesome.me/webawesome/dist/react/date-input/index.js';
Slots
Learn more about using slots.
| Name | Description |
|---|---|
clear-icon
|
An icon to use in lieu of the default clear icon. |
day-YYYY-MM-DD
|
Custom content for a specific day in the popup date picker. Slot name is dynamic (e.g., day-2026-05-25). Forwarded to <wa-date-picker>. |
end
|
An element placed at the end of the input. |
expand-icon
|
The icon to show on the date picker toggle button. Defaults to a calendar icon. |
footer
|
Content shown below the date picker inside the popup. |
hint
|
Text that describes how to use the date input. Alternatively, use the hint attribute. |
label
|
The date input's label. Alternatively, use the label attribute. |
next-icon
|
Icon for the date picker's next-page button. Forwarded to <wa-date-picker>. |
previous-icon
|
Icon for the date picker's previous-page button. Forwarded to <wa-date-picker>. |
start
|
An element placed at the start of the input. |
Attributes & Properties
Learn more about attributes and properties.
| Name | Description | Reflects |
|---|---|---|
appearanceappearance |
The date input's visual appearance.
Type
'filled' | 'outlined' | 'filled-outlined'
Default
'outlined'
|
|
assumeInteractionOn |
Native
input events do not fire on role=spinbutton elements (they aren't real <input>s). The component
dispatches a composed host input event on every segment edit, every step, and on calendar selection, so a
single input is enough to mark the field as interacted with.
Type
string[]
Default
['input']
|
|
autocompleteautocomplete |
Forwarded to the hidden form input (e.g.,
'bday', 'cc-exp') to enable browser autofill.
Type
string
Default
''
|
|
dayContent |
JS-only callback for custom day-cell content. Forwarded to the popup calendar.
Type
WaDateInputDayContent | undefined
|
|
defaultValuevalue |
The default value of the form control. Used for form reset.
Type
string
|
|
disableddisabled |
Disables the date input.
Type
boolean
Default
false
|
|
disabledDatesdisabled-dates |
Dates that cannot be selected.
Type
string | string[] | Date[]
Default
''
|
|
disabledDaysOfWeekdisabled-days-of-week |
Days of the week that cannot be selected. Accepts a space-separated list of three-letter weekday names.
Type
string
Default
''
|
|
disableFuturedisable-future |
Disable all dates strictly after today.
Type
boolean
Default
false
|
|
disablePastdisable-past |
Disable all dates strictly before today.
Type
boolean
Default
false
|
|
distancedistance |
Distance in pixels between the popup and the input.
Type
number
Default
0
|
|
firstDayOfWeekfirst-day-of-week |
The first day of the week in the popup calendar.
Type
WaDateInputFirstDayOfWeek
Default
'auto'
|
|
form |
By default, form controls are associated with the nearest containing
<form> element. This attribute allows you
to place the form control outside of a form and associate it with the form that has this id. The form must be in
the same document or shadow root for this to work.
Type
HTMLFormElement | null
|
|
hinthint |
The date input's hint. If you need to display HTML, use the
hint slot instead.
Type
string
Default
''
|
|
isDateDisabled |
JS-only callback for custom date disabling. Forwarded to the popup calendar.
Type
(date: Date) => boolean | undefined
|
|
labellabel |
The date input's label. If you need to display HTML, use the
label slot instead.
Type
string
Default
''
|
|
maxmax |
Latest selectable date as
YYYY-MM-DD. Out-of-range dates are disabled in the popup calendar and a
committed value after max fails constraint validation with rangeOverflow.
Type
string
Default
''
|
|
maxRangemax-range |
Maximum range length in days (range mode only).
0 disables.
Type
number
Default
0
|
|
minmin |
Earliest selectable date as
YYYY-MM-DD. Out-of-range dates are disabled in the popup calendar and a
committed value before min fails constraint validation with rangeUnderflow.
Type
string
Default
''
|
|
minRangemin-range |
Minimum range length in days (range mode only).
0 disables.
Type
number
Default
0
|
|
modemode |
Selection mode.
Type
WaDateInputMode
Default
'single'
|
|
monthsmonths |
Number of months rendered in the popup calendar.
Type
1 | 2
Default
1
|
|
namename |
The date input's name, submitted as a name/value pair with form data.
Type
string | null
Default
''
|
|
openopen |
Whether the popup calendar is open.
Type
boolean
Default
false
|
|
pageBypage-by |
Whether prev/next pages by the visible range or one month at a time.
Type
'months' | 'single'
Default
'months'
|
|
pillpill |
Draws a pill-style date input with rounded edges.
Type
boolean
Default
false
|
|
placementplacement |
Preferred popup placement.
Type
WaDateInputPlacement
Default
'bottom-start'
|
|
readonlyreadonly |
Makes the input non-editable. The popup still opens for browsing.
Type
boolean
Default
false
|
|
requiredrequired |
Makes the date input required for form submission.
Type
boolean
Default
false
|
|
sizesize |
The date input's size.
Type
WaDateInputSize | 'small' | 'medium' | 'large'
Default
'm'
|
|
todaytoday |
Override "today" as
YYYY-MM-DD (defaults to the runtime date).
Type
string
Default
''
|
|
validationTarget |
Override this to change where constraint validation popups are anchored.
Type
undefined | HTMLElement
|
|
validators |
Validators are static because they have
observedAttributes, essentially attributes to "watch"
for changes. Whenever these attributes change, we want to be notified and update the validator.
Type
Validator[]
Default
[]
|
|
value |
The date input's value. ISO 8601
YYYY-MM-DD for single mode, YYYY-MM-DD/YYYY-MM-DD for range mode (with
from <= to). The setter also accepts a Date or a range object with from and to properties.
Type
string
|
|
valueAsDate |
The selected date as a
Date (single mode only).
Type
Date | null
|
|
valueAsRange |
The selected range as an object with
from and to properties (range mode only).
Type
{ from: Date | null; to: Date | null }
|
|
weekdayFormatweekday-format |
Weekday header format in the popup calendar.
Type
'narrow' | 'short' | 'long'
Default
'short'
|
|
withClearwith-clear |
Shows a clear button when the date input has a value.
Type
boolean
Default
false
|
|
withHintwith-hint |
Only required for SSR. Set to
true if you're slotting in a hint element.
Type
boolean
Default
false
|
|
withLabelwith-label |
Only required for SSR. Set to
true if you're slotting in a label element.
Type
boolean
Default
false
|
|
withOutsideDayswith-outside-days |
Show leading/trailing days from adjacent months in the popup calendar.
Type
boolean
Default
false
|
|
withWeekNumberswith-week-numbers |
Show ISO 8601 week numbers in the popup calendar.
Type
boolean
Default
false
|
|
Methods
Learn more about methods.
| Name | Description | Arguments |
|---|---|---|
blur() |
Removes focus from the date input. | |
clear() |
Clears the current value and emits wa-clear, input, and change. Mirrors activating the clear button. No-op
when already empty or when disabled/readonly. |
|
focus() |
Sets focus on the first empty (else first) segment. |
options: FocusOptions
|
formStateRestoreCallback() |
Called when the browser is trying to restore element’s state to state in which case reason is "restore", or when the browser is trying to fulfill autofill on behalf of user in which case reason is "autocomplete". In the case of "restore", state is a string, File, or FormData object previously set as the second argument to setFormValue. |
state: string | File | FormData | null
|
hide() |
Closes the popup calendar. | |
resetValidity() |
Reset validity is a way of removing manual custom errors and native validation. | |
setCustomValidity() |
Do not use this when creating a "Validator". This is intended for end users of components. We track manually defined custom errors so we don't clear them on accident in our validators. |
message: string
|
show() |
Opens the popup calendar. |
Events
Learn more about events.
| Name | Description |
|---|---|
blur |
Emitted when the control loses focus. |
change |
Emitted on every committed value transition (each completed date edit, calendar selection, or clear), mirroring native <input type="date"> rather than the commit-on-blur behavior of <wa-input>/<wa-select>. This matches the sibling <wa-time-input>. It does NOT fire while a value is still incomplete. |
focus |
Emitted when the control receives focus. |
input |
Emitted on every segment edit, step, calendar interaction, and clear, even while the value is incomplete. |
wa-after-hide |
Emitted after the popup closes and animations complete. |
wa-after-show |
Emitted after the popup opens and animations complete. |
wa-clear |
Emitted when the clear button is activated. |
wa-hide |
Emitted when the popup is about to close. Cancelable. |
wa-invalid |
Emitted when the form control has been checked for validity and its constraints aren't satisfied. |
wa-show |
Emitted when the popup is about to open. Cancelable. |
CSS Custom Properties
Learn more about CSS custom properties.
| Name | Description |
|---|---|
--hide-duration |
The duration of the hide animation.
Default
var(--wa-transition-fast)
|
--show-duration |
The duration of the show animation.
Default
var(--wa-transition-fast)
|
Custom States
Learn more about custom states.
| Name | Description | CSS selector |
|---|---|---|
blank |
The date input has no committed value. |
:state(blank)
|
disabled |
The date input is disabled. |
:state(disabled)
|
open |
The popup is open. |
:state(open)
|
range |
The date input is in range mode. |
:state(range)
|
CSS Parts
Learn more about CSS parts.
| Name | Description | CSS selector |
|---|---|---|
base |
The component's base wrapper. |
::part(base)
|
clear-button |
The clear button. |
::part(clear-button)
|
date-picker |
The popup's <wa-date-picker> element. |
::part(date-picker)
|
end |
The container that wraps the end slot. |
::part(end)
|
expand-button |
The date picker toggle button. |
::part(expand-button)
|
expand-icon |
The expand icon wrapper. |
::part(expand-icon)
|
form-control |
The form control that wraps the label, input, and hint. |
::part(form-control)
|
form-control-input |
The input's wrapper. |
::part(form-control-input)
|
form-control-label |
The label's wrapper. |
::part(form-control-label)
|
hint |
The hint's wrapper. |
::part(hint)
|
input |
The segmented input group. |
::part(input)
|
input-wrapper |
The container that wraps the start slot, segmented input, clear button, and expand button. |
::part(input-wrapper)
|
popup |
The popup container. |
::part(popup)
|
range-separator |
The literal between the two groups in range mode. |
::part(range-separator)
|
segment |
Each editable segment (month/day/year spinbutton). Use [part~="segment"] to style all. |
::part(segment)
|
segment-literal |
Inert literal text between segments (separators). |
::part(segment-literal)
|
start |
The container that wraps the start slot. |
::part(start)
|
Dependencies
This component automatically imports the following elements. Sub-dependencies, if any exist, will also be included in this list.