- Add the registry
- Add date-input
Usage
DateInput splits the date into month, day and year parts, in the order its locale uses. Each part
takes typed digits and moves on to the next part once it's full, so typing 6, 1, 2, 2025
gives 06/12/2025. Typing a /, -, . or space moves on early. A part also moves on as soon as no
other digit could follow, so a 4 in the day, or a 3 in the day of February, fills it at once.
Typing letters in any part sets the month: j gives January, ju June and jul July. Typing j
again cycles through the months that start with it. A two-digit year becomes the nearest year that
ends in those digits, so 98 is 1998 and 31 is 2031. If someone leaves the field with a month and
a day but no year, the input fills in the current year.
The up and down arrow keys step a part's value, starting from today's date when the part is empty.
Page Up and Page Down step the day by a week, the month by 3 and the year by 10. Backspace clears a
part. Pasting a date such as 2025-06-12, 6/12/2025, June 12, 2025 or 12 Jun 2025 fills every
part. The day and month are read in the locale's order, unless only the other order gives a real
date. Pasting a number fills only the focused part.
The value is a Date at midnight. onValueChange receives it once every part is filled in. It
receives null once a part is cleared, or when the date doesn't exist, such as February 30, which
also makes the input invalid. To let users pick from a calendar too, use a
Date Picker, which is built on Date Input.
Examples
With a label
Put the input in a Field with a FieldLabel. Screen readers announce the
field's FieldDescription and FieldError with the input, and the input becomes invalid or
disabled along with the field. Without a visible label, give the input an aria-label.
We'll send you something on the day.
Range
With mode="range", the input holds a start date and an end date, and the value is a { from, to }
range once both are filled in. An end date before the start date makes the input invalid. Pasting a
range such as 6/26/2025 – 7/4/2025, 2025-06-26/2025-07-04 or Mar 5 – 10, 2024 fills both ends.
An end written without its year or month takes them from the other end. When a pasted range crosses
into a new year, one end moves across the year boundary: Dec 28 – Jan 3 ends in January of the
next year, or starts in December of the previous year when that's nearer to today.
Locale
The input formats the date with the order and separators of its locale, a BCP 47 tag such as
"de-DE", as Calendar's is. It also accepts month names in that language, so
pasting 3. Oktober 2025 fills it too. labels replaces the input's own text, its parts'
accessible names and its validation messages, so they match the locale. Pass only the ones you want
to change.
Earliest and latest dates
The input becomes invalid for a date before min or after max.
Any day from September to December 2025.
Unavailable dates
unavailable takes the same matchers as Calendar's unavailable. The input
becomes invalid when its date matches one of them.
We deliver on weekdays.
In a form
Give the Field or the input a name, and the value is submitted under it: a
date as YYYY-MM-DD, and a range as YYYY-MM-DD/YYYY-MM-DD, an ISO 8601 interval. When the input
is outside its form, pass the form's id as form. With required, the form won't submit without
a date, and validation fails with valueMissing. A range is submitted only once both its ends are
filled in. A partly typed date, a date that doesn't exist, or one outside min, max or
unavailable also blocks submission, failing with customError. A FieldError that matches
customError shows the reason, in the text from labels. A form reset restores defaultValue.
Sizes
size matches the sizes of Button, Input and
Select.
Invalid
Set invalid on the Field, and explain the problem with a FieldError.
Disabled
Props
Children render at the end of the input, which is where Date Picker puts
the button that opens its calendar. The file also exports formatDateValue, which formats a date or
range the way the input submits it. It returns an empty string for a range that's missing either
end.
Base UI's styling (opens in a new tab) and composition (opens in a new tab) guides say more about className, style and render.
DateInput
DateInputLabels
labels takes any of these, and uses the English default for the rest.