DateField

React Date Field components allow users to select a specific date value using a segment-based input. They are commonly used in booking forms, event scheduling, date filters, and registration flows where precise keyboard entry is preferred.

Appointment date
6152026
Select your preferred appointment date.

Installation

The Date Field relies on the react-aria-components library.

Install the component using the Tailgrids CLI.

npx @tailgrids/cli add date-field

Anatomy

import { Label } from "@/components/tailgrids/core/label";
import { Description } from "@/components/tailgrids/core/description";
import { DateField } from "@/components/tailgrids/core/date-field";
import { DateInput, DateSegment } from "@/components/tailgrids/core/date-field";

export const DateFieldExample = () => (
  <DateField>
    <Label>Appointment date</Label>
    <DateInput>{segment => <DateSegment segment={segment} />}</DateInput>
    <Description>Select your preferred appointment date.</Description>
  </DateField>
);

Examples

Basic Usage

A standard date field implementation using segments for precise date entry.

Appointment date
mmddyyyy
Select your preferred appointment date.

Controlled

Manage the date value externally using the value and onChange props.

Appointment date
6152026

Uncontrolled

An uncontrolled date field with a defaultValue prop.

Appointment date
6152026

Disabled

A disabled date field prevents user interaction.

Appointment date
6152026
This field is currently disabled.

Validation

Display error messages and validation states when the date value is outside the allowed range.

Appointment date
6152026
Select a date between the 10th and 20th.

With Date and Time

Combine date and time by using a CalendarDateTime value. Set granularity to "minute" to expose time segments.

Event date
6152026230PM

With Min / Max

Constrain the selectable date range using minValue and maxValue.

Appointment date
mmddyyyy
Available dates in June 2026.

With Leading Zeros

Use the shouldForceLeadingZeros prop to display leading zeros in day and month segments.

Appointment date
06052026
Leading zeros are shown for day and month.

International Calendar

Wrap the DateField with an I18nProvider and set the locale prop to use a different calendar system.

Appointment date
ddmmyyyyशक

API Reference

DateField

The field container that provides context for the date input and segments. Manages state, validation, and ARIA attributes.

PropTypeDefaultDescription
valueDateValue | null-The current date value (controlled).
defaultValueDateValue | null-The default date value (uncontrolled).
onChange(value: DateValue | null) => void-Handler called when the value changes.
namestring-The name of the input, used when submitting an HTML form.
formstring-The <form> element to associate the input with.
idstring-The element's unique identifier.
autoFocusbooleanfalseWhether the input should receive focus on mount.
granularity'day' | 'hour' | 'minute' | 'second''day'The smallest unit of date/time to display.
hourCycle12 | 24-Whether to use 12-hour or 24-hour format.
hideTimeZonebooleanfalseWhether to hide the time zone abbreviation.
shouldForceLeadingZerosbooleanfalseWhether to always show leading zeros in day and month.
minValueDateValue-The minimum allowed date.
maxValueDateValue-The maximum allowed date.
placeholderValueDateValue-A placeholder date value when no value is set.
orientation'vertical' | 'horizontal' | 'responsive''vertical'Layout direction of the field container.
disabledbooleanfalseWhether the input is disabled.
readOnlybooleanfalseWhether the input is read only.
requiredbooleanfalseWhether the input is required.
invalidbooleanfalseWhether the input is shown in an invalid state.
validate(value: DateValue) => ValidationResult | true | null | undefined-Custom validation function for the date value.
validationBehavior'aria' | 'native''native'Whether to use native HTML or ARIA form validation.
aria-labelstring-Defines a string that labels the current element.
aria-labelledbystring-Identifies the element (or elements) that label the element.
aria-describedbystring-Identifies the element that describes the object.
aria-detailsstring-Identifies the element providing extended description.
onBlur(e: FocusEvent) => void-Handler called when the element loses focus.
onFocus(e: FocusEvent) => void-Handler called when the element receives focus.
onFocusChange(isFocused: boolean) => void-Handler called when the element's focus status changes.
onKeyDown(e: KeyboardEvent) => void-Handler called when a key is pressed.
onKeyUp(e: KeyboardEvent) => void-Handler called when a key is released.
classNamestring-Additional CSS classes to apply to the container.

DateInput

The styled input container that wraps date segments. Supports visual state variants for form feedback.

PropTypeDefaultDescription
state'default' | 'error' | 'success''default'Visual state variant for the input container.
classNamestring | ((props: RenderProps) => string)-Additional CSS classes or render-prop className.

DateSegment

An individual editable segment of the date (day, month, year, hour, etc.).

PropTypeDefaultDescription
segmentDateSegment-The segment object from the DateInput render prop.
classNamestring | ((props: DateSegmentRenderProps) => string)-Additional CSS classes or render-prop className.

See the React Aria DateField documentation for more details.

Composition

The Date Field is composed of the root DateField component plus DateInput and DateSegment. It can be combined with shared field components (Label, Description, FieldError) for a complete form control.

DateField                                — Root container. Manages date state, validation, and ARIA context.
├── Label                                — Visible label.
├── DateInput                            — Groups editable segments into a styled input area.
│   └── DateSegment                      — Individual editable segment (day, month, year, hour, minute).
└── Description                          — Helper text.
  • Use DateField as the root. It provides the date value, validation state, and keyboard context to all children.
  • Use Label to label the field. It is automatically linked to the input.
  • Use DateInput to render the segment group. It accepts a render function that receives each segment and returns a DateSegment.
  • Use DateSegment inside DateInput to render each editable part of the date. It handles focus, typing, and arrow-key incrementing.
  • Use Description for helper text. It is automatically announced by screen readers.
  • Use FieldError for validation messages. It is linked via aria-errormessage when invalid is set.

Accessibility

  • Keyboard Support: Users can navigate between date segments (day, month, year) using Arrow keys and edit values using the number keys.
  • Screen Readers: Each segment is properly labeled and provides live updates to screen readers as values change.
  • Focus Management: Focus is managed automatically between segments for a seamless typing experience.