TimePicker
A form component for selecting time values with multiple style variants
TimePicker
The TimePicker component provides a user-friendly interface for selecting time values. It uses native time pickers on both iOS and Android platforms while offering multiple style variants to match your form design.
Import
Props
Prop | Type | Default | Description |
---|---|---|---|
value | Date | - | The currently selected time |
onChange | (date: Date) => void | - | Callback function called when the time changes |
label | string | - | Label text for the input field |
placeholder | string | 'Select time' | Placeholder text when no time is selected |
variant | 'animated' | 'classic' | 'underlined' | 'animated' | Style variant of the time picker |
error | string | - | Error message to display below the input |
is24Hour | boolean | false | Whether to use 24-hour format |
disabled | boolean | false | Whether the time picker is disabled |
containerClassName | string | - | Additional classes for the container |
Variants
TimePicker supports three style variants to match your form design:
Animated (Default)
Classic
Underlined
Basic Examples
With 24-hour Format
With Error State
Disabled State
Platform Behavior
- iOS: Shows a bottom sheet modal with a spinner-style time picker
- Android: Opens the native Android time picker dialog
Best Practices
- Choose the appropriate variant for your form design:
animated
: For forms where you want to save space while maintaining clarityclassic
: For traditional forms with simple, predictable behaviorunderlined
: For a modern, minimal aesthetic or when you want to reduce visual noise
- Use the same time format (12/24 hour) consistently throughout your app
- Provide clear error messages when time constraints are not met
- Use the same variant consistently across related form components
Features
- Native time picker integration for both iOS and Android
- Support for both 12-hour and 24-hour formats
- Floating label animation
- Error state handling
- Dark mode support
- Disabled state
- Consistent with other form components
Installation
The TimePicker component is included in the core components package. No additional installation is required.
Usage
Theming
The TimePicker follows your app's theme configuration and includes:
- Light and dark mode support
- Proper contrast for text and icons
- Animated floating label
- Focus state indicators
- Error state styling
- Disabled state styling
Examples
Basic Usage
Custom Styling
Related Components
- DatePicker - For selecting dates
- DateTimePicker - For selecting both date and time