Installations
npm install react-native-datepicker-2021
Releases
Unable to fetch releases
Developer
iannortnau
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
16.2.0
NPM Version
7.13.0
Statistics
2 Stars
177 Commits
1 Watching
4 Branches
1 Contributors
Updated on 24 Feb 2022
Languages
JavaScript (79.53%)
Objective-C (11.96%)
Starlark (4.69%)
Java (3.82%)
Total Downloads
Cumulative downloads
Total Downloads
4,085
Last day
100%
4
Compared to previous day
Last week
85.7%
26
Compared to previous week
Last month
180.4%
157
Compared to previous month
Last year
-9.2%
1,294
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
react-native-datepicker
React Native DatePicker component for both Android and iOS, using DatePickerAndroid, TimePickerAndroid and DatePickerIOS
Install
1npm install react-native-datepicker --save
Or using react-native-ui-xg, our react-naitve ui kit.
1npm install react-native-ui-xg --save
Example
Check index.android.js in the Example.
Usage
1 2import React, { Component } from 'react' 3import DatePicker from 'react-native-datepicker' 4 5export default class MyDatePicker extends Component { 6 constructor(props){ 7 super(props) 8 this.state = {date:"2016-05-15"} 9 } 10 11 render(){ 12 return ( 13 <DatePicker 14 style={{width: 200}} 15 date={this.state.date} 16 mode="date" 17 placeholder="select date" 18 format="YYYY-MM-DD" 19 minDate="2016-05-01" 20 maxDate="2016-06-01" 21 confirmBtnText="Confirm" 22 cancelBtnText="Cancel" 23 customStyles={{ 24 dateIcon: { 25 position: 'absolute', 26 left: 0, 27 top: 4, 28 marginLeft: 0 29 }, 30 dateInput: { 31 marginLeft: 36 32 } 33 // ... You can check the source to find the other keys. 34 }} 35 onDateChange={(date) => {this.setState({date: date})}} 36 /> 37 ) 38 } 39}
You can check index.js in the Example for detail.
Properties
Prop | Default | Type | Description |
---|---|---|---|
style | - | object | Specify the style of the DatePicker, eg. width, height... |
date | - | string | date | Moment instance | Specify the display date of DatePicker. string type value must match the specified format |
mode | 'date' | enum | The enum of date , datetime and time |
androidMode | 'default' | enum | The enum of default , calendar and spinner (only Android) |
format | 'YYYY-MM-DD' | string | Specify the display format of the date, which using moment.js. The default value change according to the mode. |
confirmBtnText | '确定' | string | Specify the text of confirm btn in ios. |
cancelBtnText | '取消' | string | Specify the text of cancel btn in ios. |
iconSource | - | {uri: string} | number | Specify the icon. Same as the source of Image, always using require() |
minDate | - | string | date | Restricts the range of possible date values. |
maxDate | - | string | date | Restricts the range of possible date values. |
duration | 300 | number | Specify the animation duration of datepicker. |
customStyles | - | object | The hook of customize datepicker style, same as the native style. dateTouchBody , dateInput ... |
showIcon | true | boolean | Controller whether or not show the icon |
hideText | false | boolean | Controller whether or not show the dateText |
iconComponent | - | element | Set the custom icon |
disabled | false | boolean | Controller whether or not disable the picker |
is24Hour | - | boolean | Set the TimePicker is24Hour flag. The default value depend on format . Only work in Android |
allowFontScaling | true | boolean | Set to false to disable font scaling for every text component |
placeholder | '' | string | The placeholder show when this.props.date is falsy |
onDateChange | - | function | This is called when the user confirm the picked date or time in the UI. The first and only argument is a date or time string representing the new date and time formatted by moment.js with the given format property. |
onOpenModal | - | function | This is called when the DatePicker Modal open. |
onCloseModal | - | function | This is called when the DatePicker Modal close |
onPressMask | - | function | This is called when clicking the ios modal mask |
modalOnResponderTerminationRequest | - | function | Set the callback for React Native's Gesture Responder System's call to onResponderTerminationRequest . By default this will reject a termination request, but can be overidden in case the View under the Modal is implementing custom gesture responders, and you wish for those to be overidden in certain cases. |
TouchableComponent | TouchableHighlight | Component | Replace the TouchableHighlight with a custom Component . For example : TouchableOpacity |
getDateStr | - | Function | A function to override how to format the date into a String for display, receives a Date instance |
Property customStyles
available keys
- appearance:
dateInput
,disabled
,dateTouchBody
,dateIcon
,placeholderText
,dateText
- ios select panel:
datePickerCon
,datePicker
,btnConfirm
,btnTextConfirm
,btnCancel
,btnTextCancel
Instance Methods
Method | Params | Description |
---|---|---|
onPressDate | - | Manually open the date picker panel |
onPressCancel | - | Manually close the date picker panel like, similarly pressing cancel btn |
No vulnerabilities found.
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
binaries present in source code
Details
- Warn: binary detected: android/gradle/wrapper/gradle-wrapper.jar:1
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.9
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to react-native-datepicker-2021
react-native-datepicker
React Native DatePicker component for both Android and iOS, useing DatePickerAndroid, TimePickerAndroid and DatePickerIOS
@types/react-native-datepicker
TypeScript definitions for react-native-datepicker
react-datepicker
A simple and reusable datepicker component for React
react-native-ui-datepicker
Customizable date picker for React Native