react-native-day-picker

react-native-day-picker is a simple calendar which allows you to select date range. Suites for android and ios


Keywords
calendar, picker, day-picker, date, range, native, react, react-component, react-native
License
ISC
Install
npm install react-native-day-picker@1.2.1

Documentation

react-native-day-picker

react-native-day-picker is a simple calendar which allows you select date range. Suites for android and ios.

Demo gif

Getting Started

$ npm install react-native-day-picker --save

Important: When you build app in release mode, calendar works smooth without any lags.

Note: If you use react-native v0.24 or lower install version 1.0.0

Usage

'use strict';

import React from 'react';
import {
    View,
    StyleSheet,
    AppRegistry
} from 'react-native';

import Calendar from './src/Calendar';


class DayPicker extends React.Component {
    render() {
        var from = new Date();
        from.setDate(from.getDate() - 16);
        var to = new Date();

        var startDate = new Date();
        startDate.setMonth(startDate.getMonth() + 1);

        return (
            <View style={styles.container}>
                <Calendar
                    monthsCount={24}
                    startFormMonday={true}
                    startDate={startDate}
                    selectFrom={from}
                    selectTo={to}
                    width={350}
                    onSelectionChange={(current, previous) => {
                        console.log(current, previous);
                    }}
                />
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        paddingTop: 20,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5F5F5'
    }
});

Properties

All properties are optional

  • onSelectionChange (func) β€” Function which will be executed on day click. First param is clicked day date, second one previous clicked day.

  • startDate (Date) β€” Date from which you can select dates. By default is new Date().

  • width (number) Calendars width, should be divided on 7 without remainder or may cause unpredictable behaviour.

  • selectFrom (Date) β€” First day in range that will be selected from start.

  • selectTo (Date) β€” Last day in range that will be selected from start.

  • monthsCount (number) β€” Count of dates from current months to the last.

  • startFromMonday (bool) β€” If true than months will started from monday.

  • monthsLocale (arrayOf(string)) β€” Strings for localization, which will be displayed in month header started from January.

  • weekDaysLocale (arrayOf(string)) β€” Strings for localization, which will be displayed in week day header, started from sunday.

  • isFutureDate (boolean) β€” True if you want to select a future date. By default is false.=======

  • rangeSelect (bool) β€” True if you want to select a range of dates. By default is true.

Colors

  • bodyBackColor (string) β€” Calendar background color.

  • bodyTextColor (string) β€” Calendar headers text color.

  • headerSepColor (string) β€” Calendar header separator color.

  • dayCommonBackColor (string) β€” Not selected day background color.

  • dayCommonTextColor (string) β€” Not Selected day text color.

  • dayDisabledBackColor (string) β€” Disabled day background color.

  • dayDisabledTextColor (string) β€” Disabled day text color.

  • daySelectedBackColor (string) β€” First and last day in range background color.

  • daySelectedTextColor (string) β€” First and last day in range text color.

  • dayInRangeBackColor (string) β€” In range day background color.

  • dayInRangeTextColor (string) β€” In range day text color.

  • monthTextColor (string) β€” Calendar month header text color.

Support

Email vlm.ivanchenko@gmail.com for support.