Skip to Content

TimeField

A time field allows users to enter and edit time values using a keyboard. Each part of a time 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

Event time
––––am

Sizes

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

Event time (xs)
930am
Event time (sm)
930am
Event time (md)
930am

Disabled

Event time
––––am

Read Only

Event time
930am

With Description

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

Event time
––––am
Please enter the event start time.

With Error Message

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

Event time
––––am
Please enter a valid time

Controlled

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

Event time (controlled)
1145am

Selected time: 11:45:00

Granularity

The granularity prop allows you to control the smallest unit that is displayed by the TimeField. By default, the value is displayed with "minute" granularity.

Hour only
9am
Hour and minute
930am
Hour, minute, and second
93015am

Min Time And Max Time

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

@internationalized/date includes the Time class for representing time values.

pnpm add @internationalized/date
import { Time } from "@internationalized/date"
Min time (9:00 AM)
800am
Max time (5:00 PM)
600pm

Hourly Cycle

By default, TimeField displays times in either 12 or 24 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 TimeField to use 24-hour time, regardless of the locale.

Appointment time
1530

Slots

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