A text field that reads a typed date, such as "14 mar" or "next fri", and suggests dates as you type.
import { DateField } from '@oztix/roadie-components/date-field'
Type a date the way you would say it: "14 mar", "next fri", "tomorrow", "in 2 weeks" or "1/12", which reads day first. The text is read when the field loses focus or on Enter, and the field then shows the date in the house style, such as "Fri 27 Nov 2026". The value is a plain ISO date string, '2026-11-27', or null.
Focus the empty field and a list shows what can be typed, such as Today, Next Fri and End of month, each with its date. As you type, the list offers the dates the text could mean: "fr" offers this Friday and, most days, next week's, and "14" offers the 14th of the next few months. The first one is highlighted once you type, so Enter takes it. Choose one to set the date. Words read on the calendar of timeZone, and dates that disabled refuses are left out.
dateStyle sets how the date reads when the field isn't being edited, using the date and time styles. long is the default. With another locale, the field shows and reads back that locale's month and weekday names, and English types in too. Where a local name matches an English one, the local meaning wins, so in Sesotho "27 Jan" is in June. Where a locale shows the month as a number, type the date as 1/12 or in English. Suggestions name what to type in English, such as Next Fri, and show their dates in the locale.
normal is the sunken field surface that Input uses. subtle swaps the border for a tinted fill.
Text that names no date stays in the field so it can be fixed, the field turns danger, and the value becomes null, so nothing stale is submitted. Escape puts back the last date. On its own the field only marks itself invalid; put it in a Field with Field.ErrorText to say why.
Wrap it in Field for the label, helper text and spacing. It takes invalid, required and disabled from the field.
When typed text names no date, Field.ErrorText shows why, such as "Enter a date, like 14 Mar or next Fri", even when the Field isn't marked invalid. That message wins over the error text's own children until the text is fixed. Try typing "someday".
disabled takes the same matchers as Calendar. A matched date typed in shows an error, such as "Thu 1 Oct 2026 isn't available". Here Wobbly Teacup Room only books shows from today on.
Words like "today" and "next fri" are read on the calendar of timeZone, the viewer's by default. Pass the venue's zone when the date belongs to the venue. Just after midnight in Sydney, as Saturday starts, it's still Friday in Perth.
<Field.HelperText>Type a date or a day, like 14 Mar or next Fri</Field.HelperText>
Do
Give an example in the helper text, so people know they can type words as well as dates.
<DateField placeholder='DD/MM/YYYY' />
Don’t
Don't ask for a fixed format. The field reads many, and a placeholder disappears as soon as someone types.
Do
Use DateField alone when people know the date, such as a date of birth or a date on a document.
Don’t
Don't make people type a date they would pick by weekday or week. Use DatePicker, which adds a calendar.
aria-expanded says when the list is open, and aria-activedescendant points at the highlighted suggestion, so screen readers announce it while focus stays in the text.Enter still submits the form. While the list is open, the rest of the page is hidden from screen readers, as with any open combobox; Escape or leaving the field closes it. Once you type, the first suggestion is highlighted and Enter takes it. The arrow keys move through the list, and Escape closes it and keeps the text.Tab and blur read the typed text itself, not the highlighted suggestion, and Enter reads it when no suggestion is highlighted. While text is being edited, Enter commits it instead of submitting the form, and Escape with the list closed puts back the last date instead of closing a surrounding popover or dialog.aria-invalid. Inside a Field, aria-describedby points at Field.ErrorText, which says what to type and is announced as an alert.name, a hidden input submits the ISO date, so a form never receives the formatted text. A disabled field submits nothing.A text field that reads a typed date, such as "14 mar" or "next fri", and suggests dates as you type.
The date, as an ISO date such as `'2026-11-27'`. Pair with `onValueChange`.
The date to start from when uncontrolled.
Called when typed text is committed, on blur or Enter, with an ISO date, or null when the text is empty or names no date.
`true` turns the field off. Matchers, as on `Calendar`, refuse those dates: typing one shows an error. Inherits `true` from `Field`.
Marks the field as invalid. Inherits from `Field` when omitted.
Defaults to 'md'.
Defaults to 'normal'.
How the date reads when not being edited, from the datetime formatters.
Defaults to 'long'.
Today as an ISO date, for words like "today" and "next fri".
IANA zone whose calendar decides today. Defaults to the viewer's.
First day of the week, for "next week": 1 is Monday and 7 is Sunday.
Defaults to 1.
Defaults to 'en-AU'.