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.
Use the size prop to change the size of the field. Defaults to "md"
You can add a description to the input by passing the description property.
You can combine the isInvalid and errorMessage properties to show an invalid input.
You can use the value and onChange properties to control the input value.
Selected time: 11:45:00
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.
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"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.