# react-native-daterange

> [![npm version](https://img.shields.io/npm/v/react-native-daterange.svg?style=flat-square)](https://www.npmjs.com/package/react-native-daterange) [![npm downloads](https://img.shields.io/npm/dm/react-native-daterange.svg?style=flat-square)](https://www.np

Latest version **2.3.17** (published 2019-07-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-daterange
pnpm add react-native-daterange
yarn add react-native-daterange
bun add react-native-daterange
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.17 |
| Published | 2019-07-25 |
| First published | 2019-03-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 822.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jews for Jesus |
| Maintainers | joshjoe |
| Keywords | react-native, dates, date ranges, date range, single datepicker, range datepicker, react-native-dates, calendar, datepickers, rn-dates |

## Links

- npm: https://www.npmjs.com/package/react-native-daterange
- Repository: https://github.com/jewsforjesus/react-native-daterange
- Homepage: https://github.com/jewsforjesus/react-native-daterange#readme
- Issues: https://github.com/jewsforjesus/react-native-daterange/issues
- npm.io page: https://npm.io/package/react-native-daterange

## Dependencies (4)

- [react](https://npm.io/package/react.md) >=16.8.3
- [moment](https://npm.io/package/moment.md) ^2.24.0
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2
- [moment-range](https://npm.io/package/moment-range.md) 2.2.0

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 2.3.17 (latest) — 2019-07-25
- 2.3.16 — 2019-07-25
- 2.3.15 — 2019-07-25
- 2.3.14 — 2019-07-25
- 2.3.13 — 2019-07-25
- 2.3.12 — 2019-07-14
- 2.3.11 — 2019-07-14
- 2.3.10 — 2019-04-01
- 2.3.9 — 2019-03-29
- 2.3.8 — 2019-03-29
- 2.3.6 — 2019-03-29
- 2.3.5 — 2019-03-29
- 2.3.4 — 2019-03-29
- 2.3.3 — 2019-03-29
- 2.3.2 — 2019-03-29

## README

# react-native-daterange

[![npm version](https://img.shields.io/npm/v/react-native-daterange.svg?style=flat-square)](https://www.npmjs.com/package/react-native-daterange)
[![npm downloads](https://img.shields.io/npm/dm/react-native-daterange.svg?style=flat-square)](https://www.npmjs.com/package/react-native-daterange)

## Getting started

`$ npm install react-native-daterange --save`

![alt text](https://raw.githubusercontent.com/jewsforjesus/react-native-daterange/master/ezgif.com-video-to-gif.gif)

## Usage

```javascript
import DatePicker from 'react-native-daterange';

//range picker
<DatePicker
  style={{ width: 350, height: 45 }}
  customStyles={{
    placeholderText:{ fontSize:20 } // placeHolder style
    headerStyle: {},			// title container style
    headerMarkTitle : {}, // title mark style
    headerDateTitle: {}, // title Date style
    contentInput: {}, //content text container style
    contentText: {}, //after selected text Style
  }} // optional
  centerAlign // optional text will align center or not
  allowFontScaling={false} // optional
  placeholder={'Apr 27, 2018 → Jul 10, 2018'}
  mode={'range'}
/>

//single picker
<DatePicker
  style={{ width: 350, height: 45 }}
  customStyles={{
    placeholderText:{ fontSize:20 }, // placeHolder style
    headerStyle : {},			// title container style
    headerMarkTitle : {}, // title mark style
    headerDateTitle: {}, // title Date style
    contentInput: {}, //content text container style
    contentText: {}, //after selected text Style
  }} // optional
  centerAlign // optional text will align center or not
  allowFontScaling = {false} // optional
  placeholder={'Apr 27, 2018'}
  selectedBgColor="black"
  selectedTextColor="blue"
/>


//customButton usage...
export default class NewPicker extends React.Component{
  customButtonOnPress = () => {
    console.log('customButton');
    this.picker.onConfirm();
  }
  render(){
    const {
      ...rest
    } = this.props;
    const customButton = (<Button onPress={this.customButtonOnPress} style={{ container:{ width:'80%', marginHorizontal:'3%' }, text:{ fontSize: 20 } }} primary text={'Set'}/>);
    return(
      <DatePicker
        ref = {(ref)=> this.picker = ref}
        {...rest}
        customButton = {customButton}
      />
    )
  }
}

```

## Props

| Prop                    | Type        | Description                                                                                                                            |
| :---------------------- | :---------- | :------------------------------------------------------------------------------------------------------------------------------------- |
| **`placeholder`**       | `String`    | optional.                                                                                                                              |
| **`customStyles`**      | `Object`    | optional. customize style e.g.({ placeholderText:{}, headerStyle:{} ... })                                                             |
| **`style`**             | `Object`    | Optional. date picker's style                                                                                                          |
| **`onConfirm`**         | `Function`  | Optional. call function after click button, that would return a date object {startDate:'', endDate:''} e.g( value=>console.log(value)) |
| **`selectedBgColor`**   | `String`    | Optional. custom your selected date background color e.g {"black"}                                                                     |
| **`selectedTextColor`** | `String`    | Optional. custom your selected date text color e.g {"black"}                                                                           |
| **`ButtonStyle`**       | `Object`    | Optional. custom your save button container style                                                                                      |
| **`ButtonTextStyle`**   | `Object`    | Optional. custom your save button Text style                                                                                           |
| **`returnFormat`**      | `String`    | Optional. custom your datetime format e.g.('YYYY/MM/DD') at onConfirm                                                                  |
| **`headFormat`**        | `String`    | Optional. custom your datetime format showing at headBlock e.g.('YYYY/MM/DD')                                                          |
| **`outFormat`**         | `String`    | Optional. custom your datetime format showing at outline touchable filed e.g.('YYYY/MM/DD')                                            |
| **`mode`**              | `String`    | one of ['range', 'single'] , default as single                                                                                         |
| **`customButton`**      | `component` | Optional (total custom your button component)e.g.(`<Button></Button>`)                                                                 |
| **`blockBefore`**       | `Bool`      | optional. default is false, decide blocke date before today or not                                                                     |
| **`markText`**          | `String`    | optional. default is "Select Date", you can custom this prop to label text with ur own                                                 |
| **`buttonText`**        | `String`    | optional. you can modify default button't label with your own                                                                          |
| **`blockAfter`**        | `Bool`      | optional. default is false, decide blocke date after today or not                                                                      |

....

---
_Source: https://npm.io/package/react-native-daterange · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
