React Native Calendars

1.1314.0 · active · verified Sun Apr 19

react-native-calendars is a comprehensive and highly customizable set of calendar components designed for React Native applications. It provides a variety of views including a standard month calendar, a scrollable list of calendars (CalendarList), an agenda view combining a calendar with an event list, and expandable week views. The library is actively maintained with frequent releases, often multiple times a week or month, indicating rapid development and responsiveness to bug fixes and feature requests. The current stable version is 1.1314.0. Key differentiators include extensive styling options, support for marking specific dates with various styles (dots, periods, custom backgrounds), and accessibility features. It aims to offer a robust solution for displaying and interacting with date information in mobile applications without requiring complex native module linking beyond standard React Native setup.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to render a basic calendar component, handle day selection events, apply various custom date markings, and set a custom theme. It also includes basic localization setup.

import React, { useState, useCallback } from 'react';
import { SafeAreaView, StyleSheet, Text, View } from 'react-native';
import { Calendar, LocaleConfig } from 'react-native-calendars';

// Configure localization (optional)
LocaleConfig.locales['en'] = {
  monthNames: ['January','February','March','April','May','June','July','August','September','October','November','December'],
  monthNamesShort: ['Jan.','Feb.','Mar.','Apr.','May.','Jun.','Jul.','Aug.','Sep.','Oct.','Nov.','Dec.'],
  dayNames: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
  dayNamesShort: ['Sun.','Mon.','Tue.','Wed.','Thu.','Fri.','Sat.'],
  today: 'Today'
};
LocaleConfig.defaultLocale = 'en';

const App = () => {
  const [selected, setSelected] = useState('');

  const onDayPress = useCallback((day) => {
    setSelected(day.dateString);
  }, []);

  // Define marked dates for special styling
  const markedDates = {
    [selected]: {
      selected: true,
      disableTouchEvent: true,
      selectedColor: 'orange', 
      selectedTextColor: 'white'
    },
    '2026-04-20': {dots: [{key: 'vacation', color: 'blue', selectedDotColor: 'blue'}]},
    '2026-04-21': {marked: true, dotColor: 'red'},
    '2026-04-22': {selected: true, marked: true, selectedColor: 'purple', customStyles: { text: { color: 'white' } }}
  };

  return (
    <SafeAreaView style={styles.container}>
      <Text style={styles.title}>My Calendar App</Text>
      <Calendar
        onDayPress={onDayPress}
        markedDates={markedDates}
        enableSwipeMonths={true}
        hideExtraDays={true}
        showWeekNumbers={true}
        firstDay={1} // Monday as first day of the week
        style={styles.calendar}
        theme={{
          selectedDayBackgroundColor: '#00adf5',
          todayTextColor: '#00adf5',
          arrowColor: 'orange',
          indicatorColor: 'orange',
          textMonthFontWeight: 'bold',
          textDayHeaderFontWeight: '500',
          backgroundColor: '#ffffff'
        }}
      />
      {selected && <Text style={styles.selectedDayText}>Selected day: {selected}</Text>}
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#f5fcff',
    paddingTop: 50, // Ensure content is below status bar
  },
  title: {
    fontSize: 24,
    textAlign: 'center',
    marginBottom: 20,
    fontWeight: 'bold',
    color: '#333',
  },
  calendar: {
    borderWidth: 1,
    borderColor: '#ddd',
    borderRadius: 10,
    marginHorizontal: 15,
    padding: 10,
    elevation: 3, // Android shadow
    shadowColor: '#000', // iOS shadow
    shadowOffset: { width: 0, height: 2 },
    shadowOpacity: 0.1,
    shadowRadius: 4,
  },
  selectedDayText: {
    fontSize: 18,
    textAlign: 'center',
    marginTop: 30,
    fontWeight: '600',
    color: '#00adf5',
  },
});

export default App;

view raw JSON →