Time Picker
React Time Picker components allow users to select a specific time value using a clear, scrollable interface. They are commonly used in booking forms, scheduling flows, reminders, and time-based filters.
For a segment-based keyboard input, see the Time Field component.
Installation
The Time Picker relies on the react-aria-components and react-stately libraries.
Install the component using the Tailgrids CLI.
npx @tailgrids/cli add time-pickerAnatomy
Import the component and pass the required props.
import {
TimePicker,
TimePickerTrigger
} from "@/components/tailgrids/core/time-picker";
export const TimePickerExample = () => (
<TimePicker onSelect={date => console.log(date)}>
<TimePickerTrigger>Select Time</TimePickerTrigger>
</TimePicker>
);Examples
Basic Usage
A standard time picker implementation using react-aria for accessibility. It provides a trigger button that opens a popover with scrollable columns for hours, minutes, and AM/PM selection.
With Label
You can combine the Time Picker with a label and other elements to create a complete form control.
Selected: No time selected
Custom Trigger
The TimePickerTrigger can be customized or replaced with any element that accepts refs and props.
API Reference
TimePicker
The popover-based time picker component.
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | - | Trigger element (usually TimePickerTrigger) |
onSelect | (date: Date) => void | - | Callback when hour/minute/period selection updates |
TimePickerTrigger
Extends Button props from react-aria-components.
| Prop | Type | Description |
|---|---|---|
className | string | Custom styles for the trigger button |
Accessibility
- Keyboard Support: Users can navigate the popover columns using
Arrowkeys and select values withEnter. - Screen Readers: Uses
MenuTriggerandPopoverroles to ensure screen readers announce the interactive elements correctly. - Focus Management: Focus is moved into the popover when opened and returned to the trigger upon selection or dismissal.
