Time Picker
A composable, accessible TimePicker component for modern React applications.
tsx
import { TimePicker } from '@nofinite/nui';Interactive Preview
Loading preview...
A popover-based time selection component supporting 12/24-hour clocks, minute stepping, controlled/uncontrolled usage, collision-aware positioning, and scrollable column selection UI. Designed for scheduling, booking flows, and enterprise form workflows.
Usage
Basic usage
tsx
import { TimePicker } from '@nofinite/nui';
<TimePicker />Controlled usage
tsx
const [time, setTime] = useState("13:30");
<TimePicker value={time} onChange={setTime} />24-hour clock
tsx
<TimePicker clockType={24} />Minute stepping
tsx
<TimePicker minuteStep={15} />Form integration
tsx
<TimePicker name="appointmentTime" />Disabled state
tsx
<TimePicker disabled />Variants
Clock variants
tsx
<TimePicker clockType={12} />
<TimePicker clockType={24} />Minute precision variants
tsx
<TimePicker minuteStep={5} />
<TimePicker minuteStep={30} />Control mode variants
tsx
<TimePicker defaultValue="09:00" />
<TimePicker value="10:30" />Available variants
- 12-hour timepicker
- 24-hour timepicker
- Stepped minute picker
- Full precision minute picker
- Controlled timepicker
- Uncontrolled timepicker
- Disabled timepicker
- Form-integrated timepicker
Guidelines
- Use minuteStep ≥ 5 for booking interfaces
- Prefer 24h clock in enterprise or international contexts
- Use 12h clock for consumer scheduling UX
- Keep placeholder visible until selection
- Avoid extremely fine minuteStep with mobile touch targets
States
- Closed trigger
- Open popover
- Selected item
- Hover item
- Disabled
- Placeholder state
- Focus-visible trigger
Keyboard Interaction
- Trigger opens popover via Enter / Space
- Tab navigates interactive elements
- Arrow navigation handled by scroll columns
- Escape closes popover via outside click handling
- Focus restored to trigger on close
Accessibility
- Trigger uses
aria-haspopup="dialog" aria-expandedreflects popover state- Hidden input enables native form submission
- Focus restoration improves keyboard continuity
- Scroll columns keep selected item centered
- Visual selection conveys active value
- Placeholder styling distinguishes empty state
z-dropdown | Popover layering |
Best Practices
Do
- Use stepped minutes for faster selection
- Maintain focus restoration for accessibility
- Use hidden input for non-JS form compatibility
- Prefer 24h clock for timezone-heavy apps
- Combine with date picker for scheduling workflows
Don’t
- Allow minuteStep values that break UX consistency
- Disable collision positioning for overlays
- Use extremely narrow triggers with long formatted values
- Hide popover without restoring focus
- Use timepicker for duration selection
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Standard HTML5 time format: HH:mm (24-hour format internally) |
defaultValue | string | — | Uncontrolled default time |
onChange | ((v: string) => void) | — | Callback fired when a time segment is selected |
clockType | enum | 12 | 12-hour or 24-hour clock formatting. Defaults to 12. |
minuteStep | number | 1 | Step interval for the minute column. Defaults to 1. |
placeholder | string | Select time | Placeholder text when empty |
name | string | — | Name attribute for the hidden input (for native forms) |
disabled | boolean | false | Disables the time picker trigger |