Top Related Projects
React Native Calendar Components 🗓️ 📆
An enhanced, animated, customizable Modal for React Native.
React Native Date Picker is datetime picker for Android and iOS. It includes date, time and datetime picker modes. The datepicker is customizable and is supporting different languages. It's written with native code to achieve the best possible look, feel and performance.
A React-Native datetime-picker for Android and iOS
react native datePicker component for both Android and IOS, useing DatePikcerAndroid, TimePickerAndroid and DatePickerIOS
Picker is a cross-platform UI component for selecting an item from a list of options.
Quick Overview
React Native DateTimePicker is a cross-platform component for React Native applications that provides a native UI for selecting dates and times. It supports both iOS and Android platforms, offering a seamless and consistent user experience across devices.
Pros
- Native UI components for better performance and platform-specific look and feel
- Supports both date and time picking functionalities
- Highly customizable with various props for styling and behavior control
- Actively maintained with regular updates and bug fixes
Cons
- Some inconsistencies between iOS and Android implementations
- Limited support for older React Native versions
- Occasional issues with time zone handling
- Styling options may be limited compared to custom-built solutions
Code Examples
- Basic usage for date picker:
import DateTimePicker from '@react-native-community/datetimepicker';
const [date, setDate] = useState(new Date());
<DateTimePicker
value={date}
mode="date"
display="default"
onChange={(event, selectedDate) => setDate(selectedDate)}
/>
- Time picker with custom style:
<DateTimePicker
value={date}
mode="time"
is24Hour={true}
display="spinner"
onChange={(event, selectedDate) => setDate(selectedDate)}
style={{ backgroundColor: 'white' }}
/>
- Conditional rendering based on platform:
import { Platform } from 'react-native';
{Platform.OS === 'ios' && (
<DateTimePicker
value={date}
mode="datetime"
display="inline"
onChange={(event, selectedDate) => setDate(selectedDate)}
/>
)}
Getting Started
-
Install the package:
npm install @react-native-community/datetimepicker
-
For iOS, run:
cd ios && pod install
-
Import and use in your React Native component:
import DateTimePicker from '@react-native-community/datetimepicker'; const MyComponent = () => { const [date, setDate] = useState(new Date()); return ( <DateTimePicker value={date} mode="date" display="default" onChange={(event, selectedDate) => setDate(selectedDate)} /> ); };
-
For Android, ensure you have the correct
compileSdkVersion
andtargetSdkVersion
set in yourandroid/app/build.gradle
file (usually 28 or higher).
Competitor Comparisons
React Native Calendar Components 🗓️ 📆
Pros of react-native-calendars
- More comprehensive calendar functionality, including agenda views and multi-day selection
- Highly customizable appearance and behavior
- Extensive documentation and examples
Cons of react-native-calendars
- Larger package size and potentially higher performance overhead
- Steeper learning curve due to more complex API
Code Comparison
react-native-calendars:
import {Calendar} from 'react-native-calendars';
<Calendar
markedDates={{
'2023-05-16': {selected: true, marked: true, selectedColor: 'blue'},
'2023-05-17': {marked: true},
'2023-05-18': {marked: true, dotColor: 'red', activeOpacity: 0}
}}
/>
datetimepicker:
import DateTimePicker from '@react-native-community/datetimepicker';
<DateTimePicker
value={date}
mode="date"
display="default"
onChange={onChange}
/>
The react-native-calendars library offers more advanced calendar features and customization options, making it suitable for complex calendar-based applications. However, this comes at the cost of a larger package size and potentially more complex implementation.
datetimepicker, on the other hand, provides a simpler, more lightweight solution for basic date and time picking functionality. It's easier to implement for straightforward use cases but lacks the advanced features and customization options of react-native-calendars.
Choose react-native-calendars for feature-rich calendar applications, and datetimepicker for simpler date/time selection needs.
An enhanced, animated, customizable Modal for React Native.
Pros of react-native-modal
- More versatile, can be used for various modal types beyond date/time pickers
- Highly customizable with extensive styling options
- Supports custom animations and gestures
Cons of react-native-modal
- Requires more setup and configuration for specific use cases like date/time picking
- May have a larger bundle size due to its broader feature set
- Potentially more complex API for simple modal requirements
Code Comparison
react-native-modal:
import Modal from 'react-native-modal';
<Modal isVisible={isModalVisible} onBackdropPress={toggleModal}>
<View style={styles.modalContent}>
{/* Modal content goes here */}
</View>
</Modal>
datetimepicker:
import DateTimePicker from '@react-native-community/datetimepicker';
<DateTimePicker
value={date}
mode="date"
display="default"
onChange={onChange}
/>
The react-native-modal library offers a more general-purpose modal solution with greater flexibility, while datetimepicker provides a specialized component for date and time selection. The choice between them depends on the specific requirements of your project and whether you need a dedicated date/time picker or a more versatile modal system.
React Native Date Picker is datetime picker for Android and iOS. It includes date, time and datetime picker modes. The datepicker is customizable and is supporting different languages. It's written with native code to achieve the best possible look, feel and performance.
Pros of react-native-date-picker
- More customizable appearance and functionality
- Supports both iOS and Android with a single, consistent API
- Offers additional features like minimum/maximum date limits and custom styling
Cons of react-native-date-picker
- Larger package size due to more features and customization options
- May require more setup and configuration for basic use cases
- Less integrated with React Native's core components
Code Comparison
react-native-date-picker:
import DatePicker from 'react-native-date-picker'
<DatePicker
date={date}
onDateChange={setDate}
mode="datetime"
minimumDate={new Date()}
maximumDate={new Date('2025-01-01')}
/>
datetimepicker:
import DateTimePicker from '@react-native-community/datetimepicker'
<DateTimePicker
value={date}
mode="datetime"
is24Hour={true}
display="default"
onChange={(event, selectedDate) => setDate(selectedDate)}
/>
The code comparison shows that react-native-date-picker offers more built-in props for customization, while datetimepicker has a simpler API but may require additional components or logic for advanced features. Both libraries serve similar purposes, but react-native-date-picker provides more out-of-the-box functionality at the cost of a larger package size and potentially more complex setup.
A React-Native datetime-picker for Android and iOS
Pros of react-native-modal-datetime-picker
- Provides a modal wrapper for the datetime picker, offering a more customizable UI experience
- Supports both iOS and Android platforms with a consistent API
- Offers additional styling options and customization for the modal presentation
Cons of react-native-modal-datetime-picker
- Adds an extra layer of complexity compared to the simpler datetimepicker
- May have a slightly larger bundle size due to additional modal functionality
- Requires more setup and configuration for basic usage
Code Comparison
datetimepicker:
import DateTimePicker from '@react-native-community/datetimepicker';
<DateTimePicker
value={date}
mode="date"
display="default"
onChange={onChange}
/>
react-native-modal-datetime-picker:
import DateTimePickerModal from "react-native-modal-datetime-picker";
<DateTimePickerModal
isVisible={isDatePickerVisible}
mode="date"
onConfirm={handleConfirm}
onCancel={hideDatePicker}
/>
The main difference in usage is that react-native-modal-datetime-picker requires managing the visibility state and handling confirmation/cancellation, while datetimepicker is more straightforward but less flexible in terms of presentation.
react native datePicker component for both Android and IOS, useing DatePikcerAndroid, TimePickerAndroid and DatePickerIOS
Pros of react-native-datepicker
- More customizable appearance with extensive style props
- Supports both date and time selection in a single component
- Offers a wider range of date formats and localization options
Cons of react-native-datepicker
- Less actively maintained (last update was over 2 years ago)
- May have compatibility issues with newer React Native versions
- Lacks some platform-specific features available in datetimepicker
Code Comparison
datetimepicker:
import DateTimePicker from '@react-native-community/datetimepicker';
<DateTimePicker
value={date}
mode="date"
display="default"
onChange={onChange}
/>
react-native-datepicker:
import DatePicker from 'react-native-datepicker';
<DatePicker
date={date}
mode="date"
format="YYYY-MM-DD"
onDateChange={onDateChange}
customStyles={{
dateIcon: { /* custom styles */ },
dateInput: { /* custom styles */ }
}}
/>
The main differences in usage are:
- datetimepicker uses a more modern, platform-native approach
- react-native-datepicker offers more built-in styling options
- datetimepicker separates date and time selection, while react-native-datepicker combines them
Both libraries serve similar purposes, but datetimepicker is more actively maintained and aligns better with platform-specific implementations. react-native-datepicker offers more customization out of the box but may require additional work to ensure compatibility with recent React Native versions.
Picker is a cross-platform UI component for selecting an item from a list of options.
Pros of picker
- More versatile, supporting various types of pickers beyond just date and time
- Offers a wider range of customization options for appearance and behavior
- Provides a consistent API across different picker types
Cons of picker
- Requires more setup and configuration for specific use cases like date/time picking
- May have a steeper learning curve due to its broader functionality
- Potentially larger package size due to supporting multiple picker types
Code Comparison
datetimepicker:
import DateTimePicker from '@react-native-community/datetimepicker';
<DateTimePicker
value={date}
mode="date"
display="default"
onChange={onChange}
/>
picker:
import {Picker} from '@react-native-picker/picker';
<Picker
selectedValue={selectedValue}
onValueChange={(itemValue, itemIndex) => setSelectedValue(itemValue)}
>
<Picker.Item label="Option 1" value="option1" />
<Picker.Item label="Option 2" value="option2" />
</Picker>
The datetimepicker is more specialized for date and time selection, offering a simpler API for these specific use cases. The picker, on the other hand, provides a more general-purpose solution that can be adapted for various types of selections, including dates and times with additional configuration.
While datetimepicker may be easier to implement for date/time picking, picker offers more flexibility for different types of data and custom styling. The choice between the two depends on the specific requirements of your project and the level of customization needed.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
ð§ð§ Looking for collaborators and financial backers ð§ð§
Please support maintenance of the module with a monthly donation or help us with issues and pull requests.
Become a backer on OpenCollective or sponsor us on GitHub Sponsors.
See this issue for context. Thank you!
React Native DateTimePicker
This repository was moved out of the react native community GH organization, in accordance to this proposal.
The module is still published on npm
under the old namespace (as documented) but will be published under a new namespace at some point, with a major version bump.
React Native date & time picker component for iOS, Android and Windows (please note Windows is not actively maintained).
Screenshots
Expand for screenshots
iOS | |
Android | |
Windows | |
Table of contents
- React Native DateTimePicker
- Table of contents
- Expo users notice
- Getting started
- Usage
- React Native Support
- Localization note
- Android imperative API
- Android styling
- Props / params
mode
(optional
)display
(optional
)onChange
(optional
)value
(required
)maximumDate
(optional
)minimumDate
(optional
)timeZoneName
(optional
,iOS or Android only
)timeZoneOffsetInMinutes
(optional
,iOS or Android only
)timeZoneOffsetInSeconds
(optional
,Windows only
)dayOfWeekFormat
(optional
,Windows only
)dateFormat
(optional
,Windows only
)firstDayOfWeek
(optional
,Windows only
)textColor
(optional
,iOS only
)accentColor
(optional
,iOS only
)themeVariant
(optional
,iOS only
)locale
(optional
,iOS only
)is24Hour
(optional
,Windows and Android only
)positiveButton
(optional
,Android only
)negativeButton
(optional
,Android only
)neutralButton
(optional
,Android only
)minuteInterval
(optional
)style
(optional
,iOS only
)disabled
(optional
,iOS only
)view props
(optional
,iOS only
)onError
(optional
,Android only
)
- Testing with Jest
- Migration from the older components
- Contributing to the component
- Manual installation
- Running the example app
Requirements
- Only Android API level >=21 (Android 5), iOS >= 11 are supported.
- Tested with Xcode 14.0 and RN 0.72.7. Other configurations are very likely to work as well but have not been tested.
The module supports the new React Native architecture (Fabric rendering of iOS components, and turbomodules on Android). If you are using the new architecture, you will need to use React Native 0.71.4 or higher.
Expo users notice
This module is part of Expo Managed Workflow - see docs. However, Expo SDK in the Managed Workflow may not contain the latest version of the module and therefore, the newest features and bugfixes may not be available in Expo Managed Workflow.
If you use the Managed Workflow, use the command expo install @react-native-community/datetimepicker
(not yarn
or npm
) to install this module - Expo will automatically install the latest version compatible with your Expo SDK (which may not be the latest version of the module available).
If you're using a Dev Client, rebuild the Dev Client after installing the dependencies.
If you're using the expo prebuild
command and building your native app projects (e.g. with EAS Build or locally), you can use the latest version of the module.
Getting started
npm install @react-native-community/datetimepicker --save
or
yarn add @react-native-community/datetimepicker
Autolinking is not yet implemented on Windows, so manual installation is needed.
RN >= 0.60
If you are using RN >= 0.60, only run npx pod-install
. Then rebuild your project.
React Native Support
Check the react-native
version support table below to find the corresponding datetimepicker
version to meet support requirements.
react-native version | version |
---|---|
0.73.0+ | 7.6.3+ |
<=0.72.0 | <=7.6.2 |
0.70.0+ | 7.0.1+ |
<0.70.0 | <=7.0.0 |
Usage
import DateTimePicker from '@react-native-community/datetimepicker';
Expand for examples
We give two equivalent examples on how to use the package on all supported platforms.
Recommended imperative api usage on Android
While the component-approach as given in the second paragraph works on Android, the recommended approach is to use the imperative api given in the first paragraph.
Read more about the motivation in Android imperative API.
export const App = () => {
const [date, setDate] = useState(new Date(1598051730000));
const onChange = (event, selectedDate) => {
const currentDate = selectedDate;
setDate(currentDate);
};
const showMode = (currentMode) => {
DateTimePickerAndroid.open({
value: date,
onChange,
mode: currentMode,
is24Hour: true,
});
};
const showDatepicker = () => {
showMode('date');
};
const showTimepicker = () => {
showMode('time');
};
return (
<SafeAreaView>
<Button onPress={showDatepicker} title="Show date picker!" />
<Button onPress={showTimepicker} title="Show time picker!" />
<Text>selected: {date.toLocaleString()}</Text>
</SafeAreaView>
);
};
Component usage on iOS / Android / Windows
export const App = () => {
const [date, setDate] = useState(new Date(1598051730000));
const [mode, setMode] = useState('date');
const [show, setShow] = useState(false);
const onChange = (event, selectedDate) => {
const currentDate = selectedDate;
setShow(false);
setDate(currentDate);
};
const showMode = (currentMode) => {
setShow(true);
setMode(currentMode);
};
const showDatepicker = () => {
showMode('date');
};
const showTimepicker = () => {
showMode('time');
};
return (
<SafeAreaView>
<Button onPress={showDatepicker} title="Show date picker!" />
<Button onPress={showTimepicker} title="Show time picker!" />
<Text>selected: {date.toLocaleString()}</Text>
{show && (
<DateTimePicker
testID="dateTimePicker"
value={date}
mode={mode}
is24Hour={true}
onChange={onChange}
/>
)}
</SafeAreaView>
);
};
Localization note
By localization, we refer to the language (names of months and days), as well as order in which date can be presented in a picker (month/day vs. day/month) and 12 / 24 hour-format.
On Android, the picker will be controlled by the system locale. If you wish to change it, see instructions here.
On iOS, use XCode, as documented here to inform the OS about the locales your application supports. iOS will automatically display the correctly localized DateTimePicker as long as the target language is contained in project.pbxproj
.
If you use a library like i18next or react-localize-redux to manage your translations, it is sufficient to add your target languages as described in the Apple Documentation - but you are not required to add any localization keys (like, for example, the days of the week). iOS will automatically display the correct localized strings as long as the target language is contained in
project.pbxproj
.
For testing your localization setup, refer here.
There is also the iOS-only locale prop that can be used to force locale in some cases but its usage is discouraged due to not working robustly in all picker modes (note the mixed month and day names). To the best of our knowledge, it works reliably in the spinner
mode.
For Expo, follow the localization docs.
Android imperative api
On Android, you have a choice between using the component API (regular React component) or an imperative api (think of something like ReactNative.alert()
).
While the component API has the benefit of writing the same code on all platforms, for start we recommend using the imperative API on Android.
The params
is an object with the same properties as the component props documented in the next paragraph. (This is also because the component api internally uses the imperative one.)
import { DateTimePickerAndroid } from '@react-native-community/datetimepicker';
DateTimePickerAndroid.open(params: AndroidNativeProps)
DateTimePickerAndroid.dismiss(mode: AndroidNativeProps['mode'])
The reason we recommend the imperative API is: on Android, the date/time picker opens in a dialog, similar to ReactNative.alert()
from core react native. The imperative api models this behavior better than the declarative component api. While the component approach is perfectly functional, based on the issue tracker history, it appears to be more prone to introducing bugs.
Android styling
Styling of the dialogs on Android can be easily customized by using the provided config plugin, provided that you use a Expo development build. The plugin allows you to configure color properties that cannot be set at runtime and requires building a new app binary to take effect.
Refer to this documentation for more information: android-styling.md.
Component props / params of the Android imperative api
Please note that this library currently exposes functionality from
UIDatePicker
on iOS and DatePickerDialog + TimePickerDialog on Android, andCalendarDatePicker
+ TimePicker on Windows.These native classes offer only limited configuration, while there are dozens of possible options you as a developer may need. It follows that if your requirement is not supported by the backing native views, this library will not be able to implement your requirement. When you open an issue with a feature request, please document if (or how) the feature can be implemented using the aforementioned native views. If the native views do not support what you need, such feature requests will be closed as not actionable.
mode
(optional
)
Defines the type of the picker.
List of possible values:
"date"
(default foriOS
andAndroid
andWindows
)"time"
"datetime"
(iOS
only)"countdown"
(iOS
only)
<RNDateTimePicker mode="time" />
display
(optional
)
Defines the visual display of the picker. The default value is "default"
.
List of possible values for Android
"default"
- Recommended. Show a default date picker (spinner/calendar/clock) based onmode
."spinner"
"calendar"
(only fordate
mode)"clock"
(only fortime
mode)
List of possible values for iOS (maps to preferredDatePickerStyle)
"default"
- Automatically pick the best style available for the current platform & mode."spinner"
- the usual pre-iOS 14 appearance with a wheel from which you choose values"compact"
- Affects only iOS 14 and later. Will fall back to "spinner" if not supported."inline"
- Affects only iOS 14 and later. Will fall back to "spinner" if not supported.
<RNDateTimePicker display="spinner" />
onChange
(optional
)
Date change handler.
This is called when the user changes the date or time in the UI. It receives the event and the date as parameters.
It is also called when user dismisses the picker, which you can detect by checking the event.type
property.
The values can be: 'set' | 'dismissed' | 'neutralButtonPressed'
. (neutralButtonPressed
is only available on Android).
The utcOffset
field is only available on Android and iOS. It is the offset in minutes between the selected date and UTC time.
const setDate = (event: DateTimePickerEvent, date: Date) => {
const {
type,
nativeEvent: {timestamp, utcOffset},
} = event;
};
<RNDateTimePicker onChange={this.setDate} />;
value
(required
)
Defines the date or time value used in the component.
<RNDateTimePicker value={new Date()} />
maximumDate
(optional
)
Defines the maximum date that can be selected. Note that on Android, this only works for date
mode because TimePicker does not support this.
<RNDateTimePicker maximumDate={new Date(2030, 10, 20)} />
minimumDate
(optional
)
Defines the minimum date that can be selected. Note that on Android, this only works for date
mode because TimePicker does not support this.
<RNDateTimePicker minimumDate={new Date(1950, 0, 1)} />
timeZoneName
(optional
, iOS and Android only
)
Allows changing of the time zone of the date picker. By default, it uses the device's time zone. Use the time zone name from the IANA (TZDB) database name in https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
<RNDateTimePicker timeZoneName={'Europe/Prague'} />
timeZoneOffsetInMinutes
(optional
, iOS and Android only
)
Allows changing of the time zone of the date picker. By default, it uses the device's time zone.
We strongly recommend using timeZoneName
prop instead; this prop has known issues in the android implementation (eg. #528).
This prop will be removed in a future release.
// GMT+1
<RNDateTimePicker timeZoneOffsetInMinutes={60} />
timeZoneOffsetInSeconds
(optional
, Windows only
)
Allows changing of the time zone of the date picker. By default, it uses the device's time zone.
// UTC+1
<RNDateTimePicker timeZoneOffsetInSeconds={3600} />
dayOfWeekFormat
(optional
, Windows only
)
Sets the display format for the day of the week headers. Reference: https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.calendarview.dayofweekformat?view=winrt-18362#remarks
<RNDateTimePicker dayOfWeekFormat={'{dayofweek.abbreviated(2)}'} />
dateFormat
(optional
, Windows only
)
Sets the display format for the date value in the picker's text box. Reference: https://docs.microsoft.com/en-us/uwp/api/windows.globalization.datetimeformatting.datetimeformatter?view=winrt-18362#examples
<RNDateTimePicker dateFormat="dayofweek day month" />
firstDayOfWeek
(optional
, Android and Windows only
)
Indicates which day is shown as the first day of the week.
<RNDateTimePicker firstDayOfWeek={DAY_OF_WEEK.Wednesday} />
// The native parameter type is an enum defined in defined https://docs.microsoft.com/en-us/uwp/api/windows.globalization.dayofweek?view=winrt-18362 - meaning an integer needs to passed here (DAY_OF_WEEK).
textColor
(optional
, iOS only
)
Allows changing of the textColor of the date picker. Has effect only when display
is "spinner"
.
<RNDateTimePicker textColor="red" />
accentColor
(optional
, iOS only
)
Allows changing the accentColor (tintColor) of the date picker.
Has no effect when display
is "spinner"
.
themeVariant
(optional
, iOS only
)
Allows overriding system theme variant (dark or light mode) used by the date picker. However, we recommend that you instead control the theme of the whole application using react-native-theme-control.
:warning: Has effect only on iOS 14 and later. On iOS 13 & less, use textColor
to make the picker dark-theme compatible
List of possible values:
"light"
"dark"
<RNDateTimePicker themeVariant="light" />
locale
(optional
, iOS only
)
Allows changing the locale of the component. This affects the displayed text and the date / time formatting. By default, the device's locale is used. Please note using this prop is discouraged due to not working reliably in all picker modes. Prefer localization as documented in Localization note.
<RNDateTimePicker locale="es-ES" />
is24Hour
(optional
, Windows and Android only
)
Allows changing of the time picker to a 24-hour format. By default, this value is decided automatically based on the locale and other preferences.
<RNDateTimePicker is24Hour={true} />
positiveButton
(optional
, Android only
)
Set the positive button label and text color.
<RNDateTimePicker positiveButton={{label: 'OK', textColor: 'green'}} />
neutralButton
(optional
, Android only
)
Allows displaying neutral button on picker dialog.
Pressing button can be observed in onChange handler as event.type === 'neutralButtonPressed'
<RNDateTimePicker neutralButton={{label: 'Clear', textColor: 'grey'}} />
negativeButton
(optional
, Android only
)
Set the negative button label and text color.
<RNDateTimePicker negativeButton={{label: 'Cancel', textColor: 'red'}} />
positiveButtonLabel
(optional
, Android only
, deprecated)
Changes the label of the positive button.
<RNDateTimePicker positiveButtonLabel="OK!" />
negativeButtonLabel
(optional
, Android only
, deprecated)
Changes the label of the negative button.
<RNDateTimePicker negativeButtonLabel="Negative" />
neutralButtonLabel
(optional
, Android only
, deprecated)
Allows displaying neutral button on picker dialog.
Pressing button can be observed in onChange handler as event.type === 'neutralButtonPressed'
<RNDateTimePicker neutralButtonLabel="clear" />
minuteInterval
(optional
)
The interval at which minutes can be selected.
Possible values are: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30
On Windows, this can be any number between 0-59.
on iOS, this in only supported when display="spinner"
<RNDateTimePicker minuteInterval={10} />
style
(optional
, iOS only
)
Sets style directly on picker component. By default, the picker dimensions are determined based on the props.
Please note that by default, picker's text color is controlled by the application theme (light / dark mode). In dark mode, text is white and in light mode, text is black. If you want to control the application theme, we recommend using react-native-theme-control.
This means that e.g. if the device has dark mode turned on, and your screen background color is white, you will not see the picker. Please use the Appearance
api to adjust the picker's background color so that it is visible, as we do in the example App.
Alternatively, use the themeVariant
prop.
<RNDateTimePicker style={{flex: 1}} />
disabled
(optional
, iOS only
)
If true, the user won't be able to interact with the view.
testID
(optional
)
Usually used by app automation frameworks.
Fully supported on iOS. On Android, only supported for mode="date"
.
<RNDateTimePicker testID="datePicker" />
View Props
(optional
, iOS only
)
On iOS, you can pass any View props to the component. Given that the underlying component is a native view, not all of them are guaranteed to be supported, but testID
and onLayout
are known to work.
onError
(optional
, Android only
)
Callback that is called when an error occurs inside the date picker native code (such as null activity).
Testing with Jest
For examples of how you can write your tests, look here.
Migration from the older components
Please see migration.md
Contributing to the component
Please see CONTRIBUTING.md
Manual installation
Please see manual-installation.md
Running the example app
- Run
yarn
in repo root - Run
cd example
- Install required pods by running
npx pod-install
- Run
yarn start
to start Metro Bundler - Run
yarn run start:ios
oryarn run start:android
oryarn run start:windows
- To do any development on the library, open the example project (in the
example
folder) in xCode or Android Studio. The example project depends on the library code, which you can edit and observe any changes in the example project.
This project is tested with BrowserStack.
Top Related Projects
React Native Calendar Components 🗓️ 📆
An enhanced, animated, customizable Modal for React Native.
React Native Date Picker is datetime picker for Android and iOS. It includes date, time and datetime picker modes. The datepicker is customizable and is supporting different languages. It's written with native code to achieve the best possible look, feel and performance.
A React-Native datetime-picker for Android and iOS
react native datePicker component for both Android and IOS, useing DatePikcerAndroid, TimePickerAndroid and DatePickerIOS
Picker is a cross-platform UI component for selecting an item from a list of options.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot