# react-native-calendars **Repository Path**: xinlc/react-native-calendars ## Basic Information - **Project Name**: react-native-calendars - **Description**: React Native Calendar Components - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-06-18 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # React Native Calendars ✨ 🗓️ 📆 [![NPM Version](https://img.shields.io/npm/v/react-native-calendars.svg?style=flat)](https://www.npmjs.com/package/react-native-calendars) [![Build Status](https://travis-ci.org/wix/react-native-calendars.svg?branch=master)](https://travis-ci.org/wix/react-native-calendars) This module includes various customizable react native calendar components. The package is both **Android** and **iOS** compatible. ## Try it out You can run example module by performing these steps: ``` $ git clone git@github.com:wix/react-native-calendars.git $ cd react-native-calendars/example $ npm install $ react-native run-ios ``` You can check example screens source code in [example module screens](https://github.com/wix-private/wix-react-native-calendar/tree/master/example/src/screens) This project is compatible with Expo/CRNA (without ejecting), and the examples have been [published on Expo](https://expo.io/@community/react-native-calendars-example) ## Installation ``` $ npm install --save react-native-calendars ``` The solution is implemented in JavaScript so no native module linking is required. ## Usage `import {` [Calendar](#calendar), [CalendarList](#calendarlist), [Agenda](#agenda) `} from 'react-native-calendars';` All parameters for components are optional. By default the month of current local date will be displayed. Event handler callbacks are called with `calendar objects` like this: ```javasctipt { day: 1, // day of month (1-31) month: 1, // month of year (1-12) year: 2017, // year timestamp, // UTC timestamp representing 00:00 AM of this date dateString: '2016-05-13' // date formatted as 'YYYY-MM-DD' string } ``` Parameters that require date types accept YYYY-MM-DD formated datestrings, JavaScript date objects, `calendar objects` and UTC timestamps. Calendars can be localized by adding custom locales to `LocaleConfig` object: ```javascript import {LocaleConfig} from 'react-native-calendars'; LocaleConfig.locales['fr'] = { monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'], monthNamesShort: ['Janv.','Févr.','Mars','Avril','Mai','Juin','Juil.','Août','Sept.','Oct.','Nov.','Déc.'], dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'], dayNamesShort: ['Dim.','Lun.','Mar.','Mer.','Jeu.','Ven.','Sam.'] }; LocaleConfig.defaultLocale = 'fr'; ``` ### Calendar #### Basic parameters ```javascript {console.log('selected day', day)}} // Month format in calendar title. Formatting values: http://arshaw.com/xdate/#Formatting monthFormat={'yyyy MM'} // Handler which gets executed when visible month changes in calendar. Default = undefined onMonthChange={(month) => {console.log('month changed', month)}} // Hide month navigation arrows. Default = false hideArrows={true} // Replace default arrows with custom ones (direction can be 'left' or 'right') renderArrow={(direction) => ()} // Do not show days of other months in month page. Default = false hideExtraDays={true} // If hideArrows=false and hideExtraDays=false do not swich month when tapping on greyed out // day from another month that is visible in calendar page. Default = false disableMonthChange={true} // If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday. firstDay={1} /> ``` #### Date marking Dot marking ```javascript ``` Interval marking ```javascript ``` Keep in mind that different marking types are not compatible. You can use just one marking style for calendar. #### Displaying data loading indicator The loading indicator next to month name will be displayed if `` has `displayLoadingIndicator` property and `markedDays` collection does not have a value for every day of the month in question. When you load data for days, just set `[]` or special marking value to all days in `markedDates` collection. #### Customizing look & feel ```javascript ``` ### CalendarList `` is scrollable semi-infinite calendar composed of `` components. Currently it is possible to scroll 4 years back and 4 years to the future. All paramters that are available for `` are also available for this component. There are also some additional params that can be used: ```javascript {console.log('now these months are visible', months);}} // Max amount of months allowed to scroll to the past. Default = 50 pastScrollRange={50} // Max amount of months allowed to scroll to the future. Default = 50 futureScrollRange={50} // Enable or disable scrolling of calendar list scrollEnabled={true} ...calendarParams /> ``` ### Agenda An advanced agenda component that can display interactive listings for calendar day items. ```javascript {console.log('trigger items loading')}} // callback that gets called on day press onDayPress={(day)=>{console.log('day pressed')}} // callback that gets called when day changes while scrolling agenda list onDayChange={(day)=>{console.log('day changed')}} // initially selected day selected={'2012-05-16'} // Minimum date that can be selected, dates before minDate will be grayed out. Default = undefined minDate={'2012-05-10'} // Maximum date that can be selected, dates after maxDate will be grayed out. Default = undefined maxDate={'2012-05-30'} // specify how each item should be rendered in agenda renderItem={(item, firstItemInDay) => {return ();}} // specify how each date should be rendered. day can be undefined if the item is not first in that day. renderDay={(day, item) => {return ();}} // specify how empty date content with no items should be rendered renderEmptyDate={() => {return ();}} // specify your item comparison function for increased performance rowHasChanged={(r1, r2) => {return r1.text !== r2.text}} // Hide knob button. Default = false hideKnob={true} // agenda theme theme={{ ...calendarTheme, agendaDayTextColor: 'yellow', agendaDayNumColor: 'green', agendaTodayColor: 'red' }} // agenda container style style={{}} /> ``` ## Authors * [Tautvilas Mecinskas](https://github.com/tautvilas/) - Initial code - [@tautvilas](https://twitter.com/TautviIas) * Katrin Zotchev - Initial design - [@katrin_zot](https://twitter.com/katrin_zot) See also the list of [contributors](https://github.com/wix/react-native-calendar-components/contributors) who participated in this project. ## Contributing Pull requests are welcome. `npm run test` and `npm run lint` before push.