# react-native-calendarview-datepicker

> 🌿 React-native date picker component

Latest version **0.0.12** (published 2021-01-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-calendarview-datepicker
pnpm add react-native-calendarview-datepicker
yarn add react-native-calendarview-datepicker
bun add react-native-calendarview-datepicker
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.12 |
| Published | 2021-01-02 |
| First published | 2020-08-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 1.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ravisaradev |
| Maintainers | ravisara |
| Keywords | react-native-calendarview-datepicker, react-native-calendar, react-native-datepicker, react-native, date-picker |

## Links

- npm: https://www.npmjs.com/package/react-native-calendarview-datepicker
- Repository: https://github.com/RavisaraDev/react-native-calendarview-datepicker
- Issues: https://github.com/RavisaraDev/react-native-calendarview-datepicker/issues
- npm.io page: https://npm.io/package/react-native-calendarview-datepicker

## Dependencies (1)

- [moment](https://npm.io/package/moment.md) ^2.27.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

- 0.0.12 (latest) — 2021-01-02
- 0.0.11 — 2021-01-02
- 0.0.10 — 2020-08-03
- 0.0.9 — 2020-08-03
- 0.0.8 — 2020-08-03
- 0.0.7 — 2020-08-02
- 0.0.6 — 2020-08-02
- 0.0.5 — 2020-08-01
- 0.0.4 — 2020-08-01
- 0.0.3 — 2020-08-01
- 0.0.2 — 2020-08-01
- 0.0.1 — 2020-08-01

## README

# React-native-calendarview-datepicker
![GitHub top language](https://img.shields.io/github/languages/top/RavisaraDev/react-native-calendarview-datepicker?color=yellow&style=flat-square) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/RavisaraDev/react-native-calendarview-datepicker?color=greenlabel=size&style=flat-square)  ![npm](https://img.shields.io/npm/dw/react-native-calendarview-datepicker?label=npm%20downloads&logo=npm&style=flat-square) ![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/RavisaraDev/react-native-calendarview-datepicker?color=%23C678DD&label=version&style=flat-square&logo=npm&) ![Hits](https://hitcounter.pythonanywhere.com/count/tag.svg?url=https%3A%2F%2Fgithub.com%2FRavisaraDev%2Freact-native-calendarview-datepicker)
![banner-image](./assets/banner.png?raw=true "Optional Title")

📦 Installation
----


```sh
npm i react-native-calendarview-datepicker
``` 
or

```sh
yarn add react-native-calendarview-datepicker
``` 

📺 Preview
----

![banner-image](./assets/preview-default.gif?raw=true "Optional Title") ![banner-image](./assets/preview-customized.gif?raw=true "Optional Title")


🚀 Basic Usage
----

### Default

You can simply add date-picker as follows. It shows minimal default calendar. But you can customize as you wish.
```javascript
import DatePickerCalendar from 'react-native-calendarview-datepicker';
import Moment from 'moment';

...

const App = () => {
  const [date, setDate] = useState(moment());

  return (
        <DatePickerCalendar date={date} onChange={(selectedDate) => setDate(selectedDate)}/>
  );
};
```

### Customized

You can have full control of calendar picker. Pass your own calendar header and condition styles for darkmode.
```javascript
import DatePickerCalendar from 'react-native-calendarview-datepicker';
import Moment from 'moment';

...

const App = () => {
  const [date, setDate] = useState(moment());
  
  //Custom datepicker header
const customHeader = (date, month, year, setMonth, setYear) => {
    return (
        <View style={{flexDirection: "row", justifyContent: 'space-between'}}>
            <View>
                <View>
                    <Text style={{color: "#fff", fontSize: 18, opacity: 0.5, marginBottom: 4}}>{year}</Text>
                </View>
                <View>
                    <Text style={{
                        color: "#fff",
                        fontSize: 25,
                        fontWeight: 'bold'
                    }}>{moment(date).format("MMMM Do YYYY")}</Text>
                </View>
            </View>
            <View style={{flexDirection: "row", alignItems: 'center'}}>
                <TouchableOpacity style={{
                    alignItems: 'center',
                    justifyContent: 'center',
                    marginRight: 10,
                    height: 40,
                    width: 40,
                    backgroundColor: "#155B3C",
                    borderRadius: 100
                }} onPress={() => setMonth(month - 1)}>
                    <Text style={{color: "#18D183", fontSize: 30, marginBottom: 5}}>{'‹'}</Text>
                </TouchableOpacity>
                <TouchableOpacity style={{
                    alignItems: 'center',
                    justifyContent: 'center',
                    height: 40,
                    width: 40,
                    backgroundColor: "#155B3C",
                    borderRadius: 100
                }} onPress={() => setMonth(month + 1)}>
                    <Text style={{color: "#18D183", fontSize: 30, marginBottom: 5}}>{'›'}</Text>
                </TouchableOpacity>
            </View>
        </View>
    )
}

  return (
        <DatePickerCalendar
            date={date}
            onChange={(selectedDate) => setDate(selectedDate)}
            placeholder="Select date"
            placeholderStyles={{color: "#04e37d"}}
            fieldButtonStylesDateFormat="MMM Do YY"
            fieldButtonStyles={{width: '95%', backgroundColor: "#1D323E", borderRadius: 12, borderWidth: 2, borderColor: "#18D183", paddingLeft: 20}}
            fieldButtonTextStyles={{color: "#18D183"}}
            modalBackgroundColor={"#1D323E"}
            weekHeaderTextColor={"#18D183"}
            datesColor={"#fff"}
            selectedDateColor={"#1D323E"}
            selectedDateHighlightColor={"#18D183"}
            selectedDateHighlightRadius={5}
            customHeader={(date, month, year, setMonth, setYear) => customHeader(date, month, year, setMonth, setYear)}
            headerStyles={{padding: 0}}
        />
  );
};
```


📑 API Reference
----

| Props| Type | Description 
| -------- | ------- | -------- |
| date | ```Moment``` | If your need to show placeholder on initial load just pass ```undefined```, else for default value pass ```moment()``` object
| onChange |```Function```| Callback triggered on date select (Required)
| placeholder | ```String``` | Custom placeholder text
| placeholderStyles | ```Object``` | Placeholder text styles 
| modalBackgroundColor | ```String``` | Calendar modal background color
| headerStyles | ```Object``` | Header wrapper styles
| customHeader | ```Function``` | Function should return a component. Args: ```(date, month, year, setMonth, setYear)```
| weekHeaderTextColor | ```String``` | Week days names text color
| selectedDateHighlightColor | ```String``` | Selected date highlight marker color
| selectedDateHighlightRadius | ```Number``` | Selected date highlight marker radius
| datesColor | ```String``` | Calendar date color
| selectedDateColor|  ```String``` | Selected calendar date color
| fieldButtonStylesDateFormat | ```String``` | Selected date showing format. [Available formats](https://momentjs.com/docs/#/displaying/format/)
| fieldButtonStyles | ```Object``` | Field button styles
| fieldButtonTextStyles | ```Object``` | Field button text styles


🗞 License
----

React-native-calendarview-datepicker is licensed under the [MIT License](/LICENSE)

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