React Native date & time picker component for iOS and Android, Use react-native-community / react-native-datetimepicker
Installations
npm install simple-react-native-datepicker
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
10.16.3
NPM Version
6.9.0
Score
33.6
Supply Chain
59.5
Quality
62.9
Maintenance
25
Vulnerability
92.5
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (95.28%)
JavaScript (4.72%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
LSJJOON
Download Statistics
Total Downloads
2,119
Last Day
3
Last Week
16
Last Month
38
Last Year
310
GitHub Statistics
35 Commits
1 Watching
20 Branches
1 Contributors
Package Meta Information
Latest Version
2.0.4
Package Id
simple-react-native-datepicker@2.0.4
Unpacked Size
4.18 MB
Size
1.98 MB
File Count
278
NPM Version
6.9.0
Node Version
10.16.3
Total Downloads
Cumulative downloads
Total Downloads
2,119
Last day
0%
3
Compared to previous day
Last week
60%
16
Compared to previous week
Last month
40.7%
38
Compared to previous month
Last year
31.9%
310
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
5
react-native-datepicker
React Native simple date & time picker component for iOS and Android, using @react-native-community/datetimepicker
iOS | |
Android | |
install
IMPORTANT - At first, you have to install @react-native-community/datetimepicker as a peer dependecy, and link it
1npm install --save simple-react-native-datepicker
General Usage
1import React, { Component } from 'react'; 2import { View, SafeAreaView, Text, Button } from 'react-native'; 3import DateTimePicker from 'simple-react-native-datepicker' 4 5interface IState { 6 visible: boolean; 7 dateStr?: string; 8 date?: Date; 9} 10 11class App extends Component<{}, IState> { 12 constructor(props: {}) { 13 super(props); 14 this.state = { dateStr: '', date: new Date(), visible: false }; 15 } 16 public render() { 17 return ( 18 <SafeAreaView style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> 19 <View> 20 <Text style={{ marginBottom: 20 }}>Hello! simple date picker!</Text> 21 <Text style={{ marginBottom: 20 }}>time is {String(this.state.dateStr)}</Text> 22 <Button onPress={() => this.showDatePicker()} title="show" /> 23 <DatePciker 24 visible={this.state.visible} 25 onDateChange={(dateStr, date) => this.onDateChange(dateStr, date)} 26 date={this.state.date} 27 /> 28 </View> 29 </SafeAreaView> 30 ); 31 } 32 33 public showDatePicker() { 34 this.setState({ visible: true }); 35 } 36 37 public onDateChange(dateStr?: string, date?: Date) { 38 if (dateStr === undefined) { 39 dateStr = 'canceled'; 40 } 41 this.setState({ dateStr, date, visible: false }); 42 } 43} 44 45export default App; 46
Props
visible
(required
)
Defines show or hide the picker.
1<RNDateTimePicker visible={true} /> 2 3<RNDateTimePicker visible={this.state.isShowDatePicker} />
format
(optional
)
Defines date string format. Please refer to moment format
1<RNDateTimePicker mode="date" format="YYYY-MM-DD" />
mode
(optional
)
Defines the type of the picker.
List of possible values:
"date"
(default foriOS
andAndroid
)"time"
"datetime"
(iOS
only)"countdown"
(iOS
only)
1<RNDateTimePicker mode="time" />
display
(optional
, Android only
)
Defines the visual display of the picker for Android and will be ignored for iOS.
List of possible values:
"default"
"spinner"
"calendar"
(only fordate
mode)"clock"
(only fortime
mode)
1<RNDateTimePicker display="spinner" />
onDateChange
(required
)
Date change handler.
This is called when the user changes the date or time in the UI. It receives the formatted dateStr and the date as parameters.
If dateStr and date receives undefined, it mean's datepicker canceled like press cacel button.
1setDate = (dateStr, date) => { 2 if (dateStr === undefined && date === undefined) { 3 // cancel handler execute 4 } 5}; 6 7<RNDateTimePicker onChange={this.setDate} />;
date
(optional
)
Defines the date or time value used in the component.
1<RNDateTimePicker date={new Date()} />
maximumDate
(optional
)
Defines the maximum date that can be selected.
1<RNDateTimePicker maximumDate={new Date(2300, 10, 20)} />
minimumDate
(optional
)
Defines the minimum date that can be selected.
1<RNDateTimePicker minimumDate={new Date(1950, 0, 1)} />
timeZoneOffsetInMinutes
(optional
, iOS only
)
Allows changing of the timeZone of the date picker. By default it uses the device's time zone.
1// GMT+1 2<RNDateTimePicker timeZoneOffsetInMinutes={60} />
textColor
(optional
, iOS only
)
Allows changing of the textColor of the date picker.
1<RNDateTimePicker textColor="red" />
locale
(optional
, iOS only
)
Allows changing of the locale of the component. By default it uses the device's locale. Please refer to here
1<RNDateTimePicker locale="es-ES" />
is24Hour
(optional
, Android only
)
Allows changing of the time picker to a 24 hour format.
1<RNDateTimePicker is24Hour={true} />
minuteInterval
(optional
, iOS only
)
The interval at which minutes can be selected.
Possible values are: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30
1<RNDateTimePicker minuteInterval={10} />
confirmText
(optional
, iOS only
) default = "Confirm"
Defines iOS datepicker confirm button title
1<RNDateTimePicker confirmText="확인" />
cancelText
(optional
, iOS only
) default = "Cancel"
Defines iOS datepicker cancel button title
1<RNDateTimePicker confirmText="취소" />
confirmTextStyle
(optional
, iOS only
)
Defines iOS datepicker confirm button title style
1<RNDateTimePicker confirmTextStyle={{ color: 'red' }} />
cancelTextStyle
(optional
, iOS only
)
Defines iOS datepicker cancel button title style
1<RNDateTimePicker cancelTextStyle={{ color: 'black' }} />
Running the example app
- Install required pods in
demo/ios
by runningpods install
- Run
npm start
to start Metro Bundler - Run
npm run start ios
ornpm run start android
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No security vulnerabilities found.
Other packages similar to simple-react-native-datepicker
react-native-inline-datepicker
A simple android and ios datepicker which will be rendered inline with other react-native components.
react-native-yet-another-datepicker
A react native simple date picker component without dependencies
react-jalali-datepicker
a Simple and Flexible Datepicker for react and react-native
expo-datepicker
Simple date picker