Date fields let people type a date with the keyboard. Use a DateField for an outlined text field in which a date is typed, as in the input mode of the date pickers.
To let people pick the date on a calendar, use a date picker.
import { DateField } from '@material-web/react'
import { parseDate } from '@internationalized/date'Basic date field
Set the label text with label and the date with defaultValue. The date is typed in segments, and each segment shows a placeholder until it is typed. A DateField takes no children.
import { parseDate } from '@internationalized/date'
import { DateField } from '@material-web/react'
export default function Basic() {
return <DateField label="Date" defaultValue={parseDate('2025-08-17')} className="w-80" />
}Label and supporting text
Set label to the label text, which names the field. The label rests on the date's line while the field is empty and not focused, and moves to the outline otherwise. With isRequired, it ends in an asterisk. Without a label, set an aria-label: the segments then show the date's format while the field is empty.
import { DateField } from '@material-web/react'
export default function Label() {
return (
<>
<DateField label="Date" className="w-52" />
<DateField label="Date" isRequired className="w-52" />
<DateField aria-label="Date" className="w-52" />
</>
)
}Supporting text
Set description to the text under the field. Without it, the text is the date's format, such as MM/DD/YYYY. Pass null to show no text. While the field is invalid, the error text follows it.
import { parseDate } from '@internationalized/date'
import { DateField } from '@material-web/react'
export default function Description() {
const date = parseDate('2025-08-17')
return (
<div className="flex flex-wrap items-start justify-center gap-space-200">
<DateField label="Check-in" defaultValue={date} className="w-52" />
<DateField
label="Check-in"
description="The day you arrive"
defaultValue={date}
className="w-52"
/>
<DateField label="Check-in" description={null} defaultValue={date} className="w-52" />
</div>
)
}Trailing icon
Set trailing to show an icon or an icon button at the end of the field, such as a calendar button that opens a date picker. In this example, the button is in a DialogTrigger with a DatePickerDialog, whose confirm button sets the field's value.
import { parseDate } from '@internationalized/date'
import {
Button,
DateField,
DatePicker,
DatePickerCalendar,
DatePickerContent,
DatePickerDialog,
DatePickerHeader,
DatePickerHeadline,
DialogTrigger,
Icon,
IconButton,
} from '@material-web/react'
import { useState } from 'react'
import { Heading, type DateValue } from 'react-aria-components'
export default function WithDatePicker() {
const [date, setDate] = useState<DateValue | null>(parseDate('2025-08-17'))
const [picked, setPicked] = useState(date)
return (
<DateField
label="Date"
value={date}
onChange={setDate}
className="w-80"
trailing={
<DialogTrigger onOpenChange={(isOpen) => isOpen && setPicked(date)}>
<IconButton aria-label="Calendar">
<Icon name="calendar_today" />
</IconButton>
<DatePickerDialog
dismissButton={
<Button variant="text" slot="close">
Cancel
</Button>
}
confirmButton={
<Button
variant="text"
slot="close"
isDisabled={!picked}
onPress={() => setDate(picked)}
>
OK
</Button>
}
>
<DatePicker value={picked} onChange={setPicked} autoFocus>
<DatePickerHeader>
<Heading slot="title">Select date</Heading>
<DatePickerHeadline>Selected date</DatePickerHeadline>
</DatePickerHeader>
<DatePickerContent>
<DatePickerCalendar />
</DatePickerContent>
</DatePicker>
</DatePickerDialog>
</DialogTrigger>
}
/>
)
}- An icon button is a tab stop after the segments. Give it an
aria-labelthat says what it does. A button intrailingis disabled with the field, unless it setsisDisabled={false}itself. trailingcan also be a function of the field's state:isInvalid,isDisabled,isReadOnlyandisRequired.
Controlled
Pass the date as a CalendarDate from @internationalized/date. Set the initial date with defaultValue, and the field keeps the date itself. To keep the date in your own state, control the field with value and onChange, which is called as a date is typed, and with null once every segment is cleared.
import { parseDate } from '@internationalized/date'
import { DateField } from '@material-web/react'
import { useState } from 'react'
import type { DateValue } from 'react-aria-components'
export default function Value() {
const [date, setDate] = useState<DateValue | null>(parseDate('2025-08-17'))
return (
<div className="flex flex-col gap-space-100">
<DateField label="Date" value={date} onChange={setDate} className="w-80" />
<span className="px-space-200 text-body-md text-on-surface-variant">
{date ? date.toString() : 'null'}
</span>
</div>
)
}Form props
Set isReadOnly to keep the date from being changed, and isDisabled to disable the field.
import { parseDate } from '@internationalized/date'
import { DateField } from '@material-web/react'
export default function ReadOnlyAndDisabled() {
const date = parseDate('2025-08-17')
return (
<>
<DateField label="Read-only" defaultValue={date} isReadOnly className="w-52" />
<DateField label="Disabled" defaultValue={date} isDisabled className="w-52" />
</>
)
}Validation
Set isInvalid to show the field and its supporting text in the error color.
The field can also check the date itself, as React Aria's DateField does:
- Bounds: Set
minValueandmaxValueto the first and the last date allowed. - Unavailable dates: Pass a function to
isDateUnavailablethat returnstruefor a date that is not allowed. - Your own rule: Pass a function to
validatethat returns an error message for a date, ornull.
A date that fails a check puts the field in the error state once the focus leaves the field, and the error text is shown under the supporting text. In this example, type a date outside September 2025 into the second field, then leave the field.
import { parseDate } from '@internationalized/date'
import { DateField } from '@material-web/react'
export default function Validation() {
return (
<div className="flex flex-wrap items-start justify-center gap-space-200">
<DateField
label="Invalid"
description="Pick a day in September"
defaultValue={parseDate('2025-08-17')}
isInvalid
className="w-64"
/>
<DateField
label="Check-in"
description="A day in September 2025"
minValue={parseDate('2025-09-01')}
maxValue={parseDate('2025-09-30')}
className="w-64"
/>
</div>
)
}Forms
Set a name to include the field in a form. The date is submitted as YYYY-MM-DD, and a form reset restores the initial date. Set isRequired to block the form from being submitted while the field is empty. The browser's own message is then shown as the error text.
A date that fails a check under Validation, or a field that is isInvalid, blocks the form too, unless validationBehavior is aria. See React Aria's Forms guide.
import { parseDate } from '@internationalized/date'
import { Button, DateField } from '@material-web/react'
import { useState } from 'react'
import { Form } from 'react-aria-components'
export default function InForm() {
const [sent, setSent] = useState<string | null>(null)
return (
<Form
className="flex flex-col items-start gap-space-300"
onSubmit={(event) => {
event.preventDefault()
setSent(String(new FormData(event.currentTarget).get('date')))
}}
onReset={() => setSent(null)}
>
<DateField label="Date" name="date" defaultValue={parseDate('2025-08-17')} className="w-80" />
<div className="flex gap-space-100">
<Button variant="text" type="reset">
Reset
</Button>
<Button type="submit">Submit</Button>
</div>
{sent && <p className="m-0 text-body-md text-on-surface-variant">Sent: {sent}</p>}
</Form>
)
}Localization
The field formats the date for the locale: the order of the segments, their separators and placeholders, and the format in the supporting text. The locale is the browser's by default. To set another, wrap the field in an I18nProvider from react-aria-components. See Internationalization.
import { parseDate } from '@internationalized/date'
import { DateField } from '@material-web/react'
import { I18nProvider } from 'react-aria-components'
export default function Locale() {
const date = parseDate('2025-08-17')
return (
<>
<I18nProvider locale="en-GB">
<DateField label="Date" defaultValue={date} className="w-52" />
</I18nProvider>
<I18nProvider locale="de-DE">
<DateField label="Datum" defaultValue={date} className="w-52" />
</I18nProvider>
<I18nProvider locale="ja-JP">
<DateField label="日付" defaultValue={date} className="w-52" />
</I18nProvider>
</>
)
}Date format
The format is the locale's, and no prop sets another. The segments are written with leading zeros: shouldForceLeadingZeros is true by default. Set it to false to write the digits as the locale does, such as 8/7/2025 in US English.
import { parseDate } from '@internationalized/date'
import { DateField } from '@material-web/react'
import { I18nProvider } from 'react-aria-components'
export default function Format() {
const date = parseDate('2025-08-07')
return (
<I18nProvider locale="en-US">
<DateField label="Leading zeros" defaultValue={date} className="w-52" />
<DateField
label="Locale's digits"
defaultValue={date}
shouldForceLeadingZeros={false}
className="w-52"
/>
</I18nProvider>
)
}Customization
Pass classes in className to size and place one field. See Styling for the classes, the states and the theme.
- Element: A date field is an inline flex box, aligned to the top of its line.
className,styleandrefapply to its outermost element. - Width: Set the field's width in
className, such asw-80, orw-fullto make the field as wide as the element it is in. Without a width, the field is as wide as its date. - States: On the field, style the disabled, invalid, read-only and required states with their variants, such as
invalid:. Hover and focus are reported inside the field: use thehas-*form for them, as inhas-hover:bg-surface-container. See Variants. - Functions:
classNameandstylecan be functions ofisDisabled,isInvalid,isReadOnlyandisRequired, astrailingcan. For hover and focus, pass a function asinput. - Every field: To restyle all the date fields at once, change the theme.
Custom input
Pass a function to input to render a <div> of your own around the date, in place of the field's. It is called with the props to spread on your element, including the segments and ref, and with the input's state, such as isFocusWithin and isInvalid. In this example, the element has a title, which the browser shows over the date.
import { parseDate } from '@internationalized/date'
import { DateField } from '@material-web/react'
export default function CustomInput() {
return (
<DateField
label="Date"
defaultValue={parseDate('2025-08-17')}
input={(props) => <div {...props} title="Month, day and year" />}
className="w-80"
/>
)
}Limitations
Variant and density
A date field is always outlined and 56dp tall. It has no variant, and the density classes do not change its height.
Floating label
The label on the outline extends above the field's top edge. If a scrolling box starts with a date field, give the box pt-space-100 so that the label is not cut off. A label wider than the field is cut off with an ellipsis, so keep it short.
Error text language
The error texts that the field writes itself, such as Value must be 09/01/2025 or later., are in the browser's language, not in the locale of an I18nProvider. For an error text in a language you choose, return it from validate.
Use cases
Material lists what people should be able to do with assistive technology:
- Enter dates manually by inputting text, without using the picker
Interaction and style
- States: Hovering the field darkens its outline. While the focus is in the field, the outline is 2dp thick in the primary color, and the focused segment is filled with it. An invalid field is drawn in the error color.
- Touch target: An icon button in
trailingkeeps its 48dp touch target, inside the field. - Density: A date field stays 56dp tall in every density. See Variant and density.
- Motion: With reduced motion, the label moves and the colors change at once.
- Forced colors: In forced colors, the focused segment is filled with the system's highlight color, a focused field draws its outline in it, and a disabled field is grayed out.
- Date entry methods: Material advises two ways to enter a date: typing it in the field, and a date picker that opens only from a calendar button, so that people using a keyboard or a screen reader can type the date and skip the picker. Put that button in
trailing, as in Trailing icon.
Focus
- A press anywhere on the date's line focuses a segment, and a press on the label focuses the date.
- A disabled field cannot be focused, and neither can a button in
trailing. A read-only field can be focused.
Keyboard navigation
| Keys | Actions |
|---|---|
| Tab | Move the focus to the next segment, each a separate tab stop, and then to an icon button in the field |
| Shift+Tab | Move the focus to the previous segment |
| Left or Right arrow | Move the focus to the previous or next segment |
| Up or Down arrow | Step the focused segment up or down |
| Page Up or Page Down | Step the focused segment by 7 days, 2 months or 5 years |
| Home or End | Set the focused segment to its first or last value |
| Digits | Type the focused segment, and move the focus to the next segment once it is full |
| Backspace or Delete | Clear the focused segment a digit at a time, or move the focus to the previous segment from an empty one |
- In a right-to-left locale, Left arrow and Right arrow move the focus to the segment on that side.
Labeling elements
- The
labelnames the field and each of its segments. Each segment is a spin button, named by its part of the date, such as month, and by the label. Without alabel, set anaria-label. - Use the label to state the purpose of the input, such as an event date, and the supporting text to give the date's format, as Material advises. The supporting text is the format in the locale by default, such as MM/DD/YYYY.
- The
descriptionand the error text describe the field: its first segment, and every segment while the field is invalid. - The separators between the segments are hidden from assistive technology. A month is read with its name as well as its number.
- Give an icon button in
trailinganaria-labelthat says what it does. See Icon button.
labelReactNodeThe text field's accessibility label should clearly state the purpose of the input (for example, event date or reservation date) and should match the placeholder text when the field is empty.
descriptionReactNode | nullThe helper text (below the text field) should specify the date format (for example, MM/DD/YYYY or YYYY/MM/DD) and act as a description for the text field. The default helper text is "MM/DD/YYYY," but this can be customized.
trailingReactNode | ((values: DateFieldRenderProps) => ReactNode)The calendar icon is the exclusive entry point for the date picker.
Props of DateField (37)
classNameClassNameOrFunction<DateFieldRenderProps>Default'react-aria-DateField'The CSS className for the element. A function may be provided to compute the class based on component state.
formstringThe
<form>element to associate the input with. The value of this attribute must be the id of a<form>in the same document. See MDN.idstringThe element's unique identifier. See MDN.
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.
isDisabledbooleanWhether the input is disabled.
autoFocusbooleanWhether the element should receive focus on render.
onFocus(e: FocusEvent<Target>) => voidHandler that is called when the element receives focus.
onBlur(e: FocusEvent<Target>) => voidHandler that is called when the element loses focus.
onFocusChange(isFocused: boolean) => voidHandler that is called when the element's focus status changes.
onKeyDown(e: KeyboardEvent) => voidHandler that is called when a key is pressed.
onKeyUp(e: KeyboardEvent) => voidHandler that is called when a key is released.
namestringThe name of the input element, used when submitting an HTML form. See MDN.
valuenull | ZonedDateTime | CalendarDate | CalendarDateTimeThe current value (controlled).
onChange(value: MappedDateValue<T> | null) => voidHandler that is called when the value changes.
isDateUnavailable(date: DateValue) => booleanCallback that is called for each date of the calendar. If it returns true, then the date is unavailable.
minValueDateValue | nullThe minimum allowed date that a user may select.
maxValueDateValue | nullThe maximum allowed date that a user may select.
isReadOnlybooleanWhether the input can be selected but not changed by the user.
isInvalidbooleanWhether the input value is invalid.
defaultValuenull | ZonedDateTime | CalendarDate | CalendarDateTimeThe default value (uncontrolled).
isRequiredbooleanWhether user input is required on the input before form submission.
validate(value: MappedDateValue<T>) => true | ValidationError | null | undefinedA function that returns an error message if a given value is invalid. Validation errors are displayed to the user when the form is submitted if
validationBehavior="native". For realtime validation, use theisInvalidprop instead.autoCompletestringDescribes the type of autocomplete functionality the input should provide if any. See MDN.
placeholderValuenull | ZonedDateTime | CalendarDate | CalendarDateTimeA placeholder date that influences the format of the placeholder shown when no value is selected. Defaults to today's date at midnight.
hourCycle12 | 24Whether to display the time in 12 or 24 hour format. By default, this is determined by the user's locale.
granularity'day' | 'hour' | 'minute' | 'second'Determines the smallest unit that is displayed in the date picker. By default, this is
"day"for dates, and"minute"for times.hideTimeZonebooleanDefaultfalseWhether to hide the time zone abbreviation.
shouldForceLeadingZerosbooleanWhether to always show leading zeros in the month, day, and hour fields. By default, this is determined by the user's locale.
validationBehavior'native' | 'aria'Default'native'Whether to use native HTML form validation to prevent form submission when the value is missing or invalid, or mark the field as required or invalid via ARIA.
styleCSSProperties | (values: DateFieldRenderProps & { defaultStyle: CSSProperties; }) => CSSProperties | undefinedThe inline style for the element. A function may be provided to compute the style based on component state.
renderDOMRenderFunction<'div', DateFieldRenderProps>Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components.
Requirements:
- You must render the expected element type (e.g. if
<button>is expected, you cannot render an<a>). - Only a single root DOM element can be rendered (no fragments).
- You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
- You must render the expected element type (e.g. if
slotstring | nullA slot name for the component. Slots allow the component to receive props from a parent component. An explicit
nullvalue indicates that the local props completely override all props received from a parent.refRef<HTMLDivElement>inputAriaDateInputProps['render']
DateField also takes the 70 attributes and events of the element it renders.