Introduction
Components
- Accordion
- Action Sheet
- Alert
- Audio Player
- Audio Recorder
- Audio Waveform
- Avatar
- AvoidKeyboard
- Badge
- BottomSheet
- Button
- Camera
- Camera Preview
- Card
- Carousel
- Checkbox
- Collapsible
- Color Picker
- Combobox
- Date Picker
- File Picker
- Gallery
- Hello Wave
- Icon
- Image
- Input
- Input OTP
- Link
- MediaPicker
- Mode Toggle
- Onboarding
- ParallaxScrollView
- Picker
- Popover
- Progress
- Radio
- ScrollView
- SearchBar
- Separator
- Share
- Sheet
- Skeleton
- Spinner
- Switch
- Table
- Tabs
- Text
- Toast
- Toggle
- Video
- View
Charts
Installation
pnpm dlx bna-ui add date-picker
Usage
import { DatePicker } from '@/components/ui/date-picker';
const [selectedDate, setSelectedDate] = useState<Date | undefined>();
<DatePicker
label='Select Date'
value={selectedDate}
onChange={setSelectedDate}
placeholder='Choose a date'
/>;
Examples
Default
Time Picker
Date Time Picker
Date Range
With Constraints
Different Variants
Time Formats
Form Integration
API Reference
DatePicker
The main date picker component that handles date and time selection.
Prop | Type | Default | Description |
---|---|---|---|
label | string | - | Label text displayed above the picker. |
value | Date | - | The currently selected date. |
onChange | (date: Date) => void | - | Callback fired when the date changes. |
mode | 'date' | 'range' | 'time' | 'datetime' | 'date' | The picker mode - date only, time only, or both. |
placeholder | string | 'Select date' | Placeholder text when no date is selected. |
disabled | boolean | false | Whether the picker is disabled. |
error | string | - | Error message to display. |
minimumDate | Date | - | The minimum selectable date. |
maximumDate | Date | - | The maximum selectable date. |
timeFormat | '12' | '24' | '24' | Time format for time and datetime modes. |
variant | 'filled' | 'outline' | 'group' | 'filled' | Visual variant of the picker trigger. |
style | ViewStyle | - | Additional styles for the trigger container. |
labelStyle | TextStyle | - | Additional styles for the label text. |
errorStyle | TextStyle | - | Additional styles for the error text. |
Features
Multiple Modes
- Date Mode: Calendar-based date selection
- Range Mode: Calendar-based range date selection
- Time Mode: Hour and minute selection with scrollable lists
- DateTime Mode: Combined date and time selection with step-by-step flow
Flexible Time Formats
- 24-hour format: Standard 24-hour time display (00:00 - 23:59)
- 12-hour format: AM/PM time display with period selector
Date Constraints
- Set minimum and maximum selectable dates
- Automatic disabling of invalid dates
- Visual feedback for disabled dates
Customizable Variants
- Filled: Default filled background style
- Outline: Border-only style with transparent background
- Group: Minimal style for use within form groups
Accessibility Features
- Full screen reader support
- Keyboard navigation compatibility
- High contrast mode support
- Proper focus management
Navigation
- Month/year quick selection
- Smooth navigation between months
- Today button for quick access to current date
- Intuitive calendar grid layout
Accessibility
The DatePicker component follows accessibility best practices:
- Uses semantic markup for screen readers
- Provides proper ARIA labels and descriptions
- Supports keyboard navigation
- Maintains focus management in the bottom sheet
- Offers high contrast support for visually impaired users
- Includes proper error announcement
Customization
The component uses your theme colors and can be customized through:
- Theme color overrides
- Custom styling props
- Variant selection
- Label and error styling
- Container styling
Performance
- Optimized calendar calculations with useMemo
- Efficient date validation
- Minimal re-renders with proper callback optimization
- Smooth scrolling in time pickers
On This Page
InstallationUsageExamplesDefaultTime PickerDate Time PickerDate RangeWith ConstraintsDifferent VariantsTime FormatsForm IntegrationAPI ReferenceDatePickerFeaturesMultiple ModesFlexible Time FormatsDate ConstraintsCustomizable VariantsAccessibility FeaturesNavigationAccessibilityCustomizationPerformance