This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 54).
A Jetpack Compose DateTimePicker component for selecting dates and times.
A date and time picker component that allows users to select dates, times, or both using native Android dialogs.
Installation
- npx expo install @expo/uiIf you are installing this in an existing React Native app, make sure to install expo in your project.
Date time picker
import { DateTimePicker } from '@expo/ui/jetpack-compose'; <DateTimePicker onDateSelected={date => { setSelectedDate(date); }} displayedComponents='date' initialDate={selectedDate.toISOString()} variant='picker' />
See Official Jetpack Compose documentation for more information.
Time picker
import { DateTimePicker } from '@expo/ui/jetpack-compose'; <DateTimePicker onDateSelected={date => { setSelectedDate(date); }} displayedComponents='hourAndMinute' initialDate={selectedDate.toISOString()} variant='picker' />
See Official Jetpack Compose documentation for more information.
API
Component
Type: React.Element<DateTimePickerProps>
Renders a DateTimePicker component.
DisplayedComponents • Default: 'date'The components that the picker should display.
On Android, you can have a picker that selects just the date or just the time.
dateAndTime is only available on iOS and will result in a date picker on Android.
On iOS, you can have a picker that selects both date and time.
unionThe initial date to display on the picker.
Acceptable values are: string | null
boolean • Default: trueDetermines what format the clock should be displayed in on Android.
(date: Date) => voidCallback function that is called when a date is selected.
boolean • Default: trueShow to button to toggle between variants on Android.
AndroidVariant • Default: 'picker'The variant of the picker, which determines its appearance and behavior.