This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
日期时间选择器
一个用于选择日期和时间的 Jetpack Compose 日期时间选择器组件。
Expo UI DateTimePicker 与官方 Jetpack Compose 日期选择器 和 时间选择器 API 保持一致,并支持日期、时间以及组合选择。
注意: 日期变体会渲染 Material 的日历网格和输入字段,这两者都会在内部水平滚动。父级
Host必须在水平方向提供有限宽度,请将matchContents={{ vertical: true }}与style={{ width: '100%' }}一起使用(或任何有限宽度)。有关详细信息,请参阅 Host 参考中的匹配内容。


安装
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
日期选择器
时间选择器
输入变体
使用 variant="input" 会将选择器显示为文本输入字段,而不是默认的选择器 UI。
API
import { DateTimePicker } from '@expo/ui/jetpack-compose';
Components
Type: React.Element<DatePickerDialogProps>
ColorValueDatePickerElementColors & TimePickerElementColors(date: Date) => voidAndroidVariantType: React.Element<DateTimePickerProps>
Renders an inline DateTimePicker component.
ColorValueThe tint color to use on the picker elements.
When elementColors is not provided, this color is applied to a subset of
picker elements (selected day, title, headline, today border for date picker;
selector, selected time segment, clock dial for time picker).
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.
DatePickerElementColors & TimePickerElementColorsFine-grained color overrides for individual picker elements.
When provided, these take precedence over the color prop.
Date picker color keys are used when displayedComponents is 'date' or 'dateAndTime'.
Time picker color keys are used when displayedComponents is 'hourAndMinute'.
Unset values fall back to Material 3 theme defaults.
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.
Constrains which dates can be selected. Mirrors the native Compose selectableDates parameter.
start is the earliest selectable date, end is the latest.
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.
Type: React.Element<TimePickerDialogProps>
ColorValueDatePickerElementColors & TimePickerElementColors(date: Date) => voidTypes
Color overrides for the Material 3 DatePicker component. All properties are optional — unset values use Material 3 theme defaults.
Literal type: string
Acceptable values are: 'date' | 'hourAndMinute' | 'dateAndTime'