Docyrus

DateTimePicker

A date and time picker using the native platform picker with ActionSheet presentation on iOS and dialog on Android.

iOSAndroid
Preview DateTimePicker on your device

Scan with Expo Go

Download Expo Go, then scan the QR code to preview native components.

Installation

pnpm dlx @docyrus/cli add @docyrus/rn-date-time-picker
Required Packages(1 package)
pnpm add @react-native-community/datetimepicker

The native picker is loaded via dynamic require() — the component renders a fallback message if the package is not installed.

Usage

import { DateTimePicker } from '@/components/docyrus-native/date-time-picker';

<DateTimePicker
  value={new Date()}
  onChange={(date) => console.log(date)}
  format="datetime"
/>

Date only

<DateTimePicker value={date} onChange={setDate} format="date" />

Time only

<DateTimePicker value={date} onChange={setDate} format="time" />

Controlled visibility (for embedding in forms)

const [open, setOpen] = useState(false);

<DateTimePicker
  value={date}
  onChange={setDate}
  format="date"
  open={open}
  onOpenChange={setOpen}
/>

When open and onOpenChange are provided, the built-in trigger button is not rendered — the parent controls visibility.

Label and 12-hour clock

<DateTimePicker label="Due date" value={date} onChange={setDate} use24HourFormat={false} />

When use24HourFormat is omitted and a <DateFormatProvider> (e.g. DocyrusTenantProvider) is mounted, the trigger uses the tenant's formatDate / formatTime / formatDateTime; otherwise it renders dd.MM.yyyy HH:mm.

API Reference

PropTypeDefaultDescription
valueDate | null—The currently selected date/time value.
onChange(date: Date | null) => void—Fired when the user confirms (Done / Android dialog) or clears the selection.
minDateDate—Minimum selectable date.
maxDateDate—Maximum selectable date.
disabledbooleanfalseDisables the picker trigger.
placeholderstringsheet titleTrigger text when no value is selected.
format'datetime' | 'date' | 'time''datetime'Picker mode.
size'sm' | 'md' | 'lg' | 'default''md'Trigger size ('default' is the web alias of 'md'). Also sizes the label.
clearablebooleantrueShow the Clear button in the picker header.
use24HourFormatboolean—true = 24-hour, false = 12-hour AM/PM trigger text. Omitted → DateFormatProvider when mounted, else 24-hour. Android's native dialog follows it (is24Hour); the iOS spinner follows the device clock.
labelstring—Optional label rendered above the trigger (uncontrolled mode).
messagesPartial<DateTimePickerMessages>—App-supplied copy; wins over <UiTranslationProvider>.
openboolean—Controlled visibility. When provided, no built-in trigger is rendered.
onOpenChange(open: boolean) => void—Callback when picker visibility changes.
classNamestring—Additional class names for the trigger (or the label wrapper when label is set).
styleViewStyle—Additional styles for the trigger (or the label wrapper).

DateTimePickerMessages

Every key falls back to t('ui.dateTimePicker.<key>', …).

KeyFallbackDescription
selectDate'Select Date'Sheet title for date mode.
selectTime'Select Time'Sheet title for time mode.
selectDateTime'Select Date & Time'Sheet title for datetime mode.
cancel'Cancel'Cancel button label.
done'Done'Done button label.
clear'Clear'Clear button label.
fallback'Install @react-native-community/datetimepicker for native picker'Shown when the native picker is not installed.

Platform Behavior

PlatformPresentationPicker type
iOSActionSheet with spinner — changes are a draft until Done; dismissing discardsNative UIDatePicker (spinner mode)
AndroidNative dialog; datetime runs a date dialog followed by a time dialogDatePickerDialog / TimePickerDialog
No native pickerInline fallback message—

Exported Helpers

ExportTypeDescription
formatPickerDate(date, mode, dateFormat?, timeFormat?) => stringFormat a date for display. 'short' / 'medium' render dd.MM.yyyy HH:mm; 'long' / 'full' use Intl with timeFormat ('12h' default). Used by form fields.

Components

ComponentDescription
DateTimePickerTrigger + native date/time picker

Type Exports

TypeDescription
DateTimePickerPropsProps for the DateTimePicker component.
DateTimePickerFormat'datetime' | 'date' | 'time' — picker mode.
DateTimePickerSize'sm' | 'md' | 'lg' | 'default'
DateTimePickerMessagesApp-supplied copy.
DateTimeMinuteInterval1 | 5 | 10 | 15 | 30

Differences from web

The web DateTimePicker is bound to react-hook-form (form / field); native is value-based (value / onChange) and integrates with forms through form-fields. The web autoFocus (keyboard focus of the popover calendar) has no native equivalent.

On this page