Skip to Content

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.

There is not much change in this component as compared to react-aria-components's export. You can refer to the official documentation for more details.

Usage

Birth date
ddmmyyyy

Sizes

Use the size prop to change the size of the field. Defaults to "md"

Event date (xs)
04112025345amGMT-8
Event date (sm)
04112025345amUTC
Event date (md)
04112025345amGMT+9

Disabled

Birth date
ddmmyyyy

Read Only

Birth date
27072019

With Description

You can add a description to the input by passing the description property.

Birth date
ddmmyyyy
Please enter your birth date.

With Error Message

You can combine the isInvalid and errorMessage properties to show an invalid input.

Birth date
ddmmyyyy
Please enter a valid date

Controlled

You can use the value and onChange properties to control the input value.

Date (controlled)
04042024

Selected date: Thursday, 4 April 2024

Time Zones

DateField is timezone aware when a ZonedDateTime object is provided as the value. In this case, the time zone abbreviation is displayed, and time zone concerns such as daylight saving time are taken into account when the value is manipulated.

@internationalized/date includes functions for parsing strings in multiple formats into ZonedDateTime objects.

pnpm add @internationalized/date
import { parseZonedDateTime } from "@internationalized/date"
Event date
04112025345amGMT-8
Event date
04112025345amUTC

Min Date And Max Date

The minValue and maxValue props can also be used to ensure the value is within a specific range.

@internationalized/date includes functions for parsing strings in multiple formats into ZonedDateTime objects.

pnpm add @internationalized/date
import { getLocalTimeZone, parseDate, today } from "@internationalized/date"
Min date
17122025
Max date
19122025

Hide Time Zone

When a ZonedDateTime object is provided as the value to DateField, the time zone abbreviation is displayed by default. However, if this is displayed elsewhere or implicit based on the usecase, it can be hidden using the hideTimeZone option.

@internationalized/date includes functions for parsing strings in multiple formats into ZonedDateTime objects.

pnpm add @internationalized/date
import { parseZonedDateTime } from "@internationalized/date"
Appointment time
071120221245am

Hourly Cycle

By default, DateField displays times in either 12 or 24 hour hour format depending on the user's locale. However, this can be overridden using the hourCycle prop if needed for a specific usecase. This example forces DateField to use 24-hour time, regardless of the locale.

@internationalized/date includes functions for parsing strings in multiple formats into ZonedDateTime objects.

Appointment time
041120251555SGT

Slots

  • base: Input wrapper, it handles alignment, placement, and general appearance.
  • label: Label of the date-input, it is the one that is displayed above, inside or left of the date-input.
  • input: The date-input element.
  • description: The description of the date-input.
  • error: The error message of the date-input.