DateField

A date field allows users to enter and edit date and time values using a keyboard. Each part of a date value is displayed in an individually editable segment.

Theme 
Date
mmddyyyy
 
granularity 
isDisabled 
Example
DateField.tsx
DateField.css
import {DateField} from './DateField';

<DateField label="Date" />

Value

Use the value or defaultValue prop to set the date value, using objects in the @internationalized/date package. This library supports parsing date strings in multiple formats, manipulation across international calendar systems, time zones, etc.

232020

Selected date: Monday, February 3, 2020

import {parseDate, getLocalTimeZone, type CalendarDate} from '@internationalized/date';
import {useDateFormatter} from 'react-aria';
import {DateField} from './DateField';
import {useState} from 'react';

function Example() {
  let [date, setDate] = useState<CalendarDate | null>(parseDate('2020-02-03'));
  let formatter = useDateFormatter({ dateStyle: 'full' });

  return (
    <>
      <DateField
        value={date}
        onChange={setDate} />
      <p>Selected date: {date ? formatter.format(date.toDate(getLocalTimeZone())) : '--'}</p>
    </>
  );
}

Format options

The date format is automatically determined based on the user's locale. DateField supports several props to control how values are displayed.

Date
232025845AMPST
granularity 
hourCycle 
hideTimeZone 
shouldForceLeadingZeros 
import {parseZonedDateTime} from '@internationalized/date';
import {DateField} from './DateField';

<DateField
  label="Date"
  defaultValue={parseZonedDateTime('2025-02-03T08:45:00[America/Los_Angeles]')} />

International calendars

By default, DateField displays the value using the calendar system for the user's locale. Use <I18nProvider> to override the calendar system by setting the Unicode calendar locale extension. The onChange event always receives a date in the same calendar as the value or defaultValue (Gregorian if no value is provided), regardless of the displayed locale.

14111946शक845amGMT-8
Locale
Calendar
import {I18nProvider} from 'react-aria-components';
import {parseZonedDateTime} from '@internationalized/date';
import {DateField} from './DateField';

<I18nProvider locale="hi-IN-u-ca-indian">
  <DateField defaultValue={parseZonedDateTime('2025-02-03T08:45:00[America/Los_Angeles]')} />
</I18nProvider>

Forms

Use the name prop to submit the selected date to the server as an ISO 8601 string. Set the isRequired, minValue, or maxValue props to validate the value, or implement custom client or server-side validation. See the Forms guide to learn more.

Appointment date
mmddyyyy
import {today, getLocalTimeZone} from '@internationalized/date';
import {DateField} from './DateField';
import {Button} from './Button';
import {Form} from './Form';;

<Form>
  <DateField
    label="Appointment date"
    name="date"
    isRequired
    minValue={today(getLocalTimeZone())}
  />
  <Button type="submit">Submit</Button>
</Form>

API

Shows a date field with labels pointing to its parts, including the label, field, and segments.Event date8 / 15 / 2022SegmentFieldLabel
<DateField>
  <Label />
  <DateInput>
    {segment => <DateSegment segment={segment} />}
  </DateInput>
  <Text slot="description" />
  <FieldError />
</DateField>

DateField

A date field allows users to enter and edit date and time values using a keyboard. Each part of a date value is displayed in an individually editable segment.

NameTypeDefault
isDateUnavailable(date: ) => booleanDefault:
Callback that is called for each date of the calendar. If it returns true, then the date is unavailable.
placeholderValuenullDefault:
A placeholder date that influences the format of the placeholder shown when no value is selected. Defaults to today's date at midnight.
hourCycle1224Default:
Whether to display the time in 12 or 24 hour format. By default, this is determined by the user's locale.
granularityDefault:
Determines the smallest unit that is displayed in the date picker. By default, this is "day" for dates, and "minute" for times.
hideTimeZonebooleanDefault: false
Whether to hide the time zone abbreviation.
shouldForceLeadingZerosbooleanDefault:
Whether to always show leading zeros in the month, day, and hour fields. By default, this is determined by the user's locale.
isDisabledbooleanDefault:
Whether the input is disabled.
isReadOnlybooleanDefault:
Whether the input can be selected but not changed by the user.
children<>Default:
The children of the component. A function may be provided to alter the children based on component state.
valuenullDefault:
The current value (controlled).
defaultValuenullDefault:
The default value (uncontrolled).
onChange(value: <>null) => voidDefault:
Handler that is called when the value changes.

Default className: react-aria-DateField

Render PropCSS Selector
stateCSS Selector:
State of the date field.
isInvalidCSS Selector: [data-invalid]
Whether the date field is invalid.
isDisabledCSS Selector: [data-disabled]
Whether the date field is disabled.
isReadOnlyCSS Selector: [data-readonly]
Whether the date field is read only.

DateInput

A date input groups the editable date segments within a date field.

NameType
children(segment: ) => ReactElement

Default className: react-aria-DateInput

Render PropCSS Selector
isHoveredCSS Selector: [data-hovered]
Whether the date input is currently hovered with a mouse.
isFocusWithinCSS Selector: [data-focus-within]
Whether an element within the date input is focused, either via a mouse or keyboard.
isFocusVisibleCSS Selector: [data-focus-visible]
Whether an element within the date input is keyboard focused.
isDisabledCSS Selector: [data-disabled]
Whether the date input is disabled.
isInvalidCSS Selector: [data-invalid]
Whether the date input is invalid.

DateSegment

A date segment displays an individual unit of a date and time, and allows users to edit the value by typing or using the arrow keys to increment and decrement.

NameType
segment
children<>
The children of the component. A function may be provided to alter the children based on component state.

Default className: react-aria-DateSegment

Render PropCSS Selector
isHoveredCSS Selector: [data-hovered]
Whether the segment is currently hovered with a mouse.
isFocusedCSS Selector: [data-focused]
Whether the segment is focused, either via a mouse or keyboard.
isFocusVisibleCSS Selector: [data-focus-visible]
Whether the segment is keyboard focused.
isPlaceholderCSS Selector: [data-placeholder]
Whether the value is a placeholder.
isReadOnlyCSS Selector: [data-readonly]
Whether the segment is read only.
isDisabledCSS Selector: [data-disabled]
Whether the date field is disabled.
isInvalidCSS Selector: [data-invalid]
Whether the date field is in an invalid state.
typeCSS Selector: [data-type="..."]
The type of segment. Values include literal, year, month, day, etc.
textCSS Selector:
The formatted text for the segment.
placeholderCSS Selector:
A placeholder string for the segment.