Skip to content

React Calendar Documentation: Installation, Usage, and Customization Guide

Welcome to our documentation for React Calendar! 📖 In this guide, you will learn how to install and use the React Calendar package and customize it to suit your needs.

For full official npm documentation visit npm-React-Calendar

For React Calendars official webpage visit React-Calendar

Want to try a live demo? Visit Live Demo

What is React Calendar? 📆

React Calendar is a lightweight calendar package designed for use in React applications. It provides a simple and customizable way to display calendars and schedule events. It is currently being managed by a developer under the name Wojciech Maj. The developer has made this incredible tool light and fast, extremely customizable, works with any language, is rock-solid/bug-free, and, best of all, open source! (Forever)

Intended Users

Our documentation is targeted towards the following users:

Beginner developers who need to set up a React Calendar for a personal project.

Info

Prerequisites:

  • Basic understanding of Command Line Interface.
  • Basic knowledge of Visual Studio Code.
  • Basic knowledge of Node package manager.

Getting Started

To use React Calendar in your project, you'll need to have the following pre-requisites installed:

Node JS Node Environment is required to use React and React Calendar

Visual Studio Code Working with documentation requires a text editor, please install VS Code, or you can work with your favorite text editor

React Calendar

React Calendar

Basic Usage

Once you have React Calendar installed, you can use it in your React application by importing the Calendar component and rendering it in your component. If you are not familiar with React, this may be a difficult task at first, that's why we are going to show you. 😎 Here's an example of how to use React Calendar in a basic React component:

import React, { useState } from 'react';
import Calendar from 'react-calendar';

function MyApp() {
    const [value, onChange] = useState(new Date());

    return (
        <div>
            <Calendar onChange={onChange} value={value} />
        </div>
    );
}
export default MyApp;

So in this example, we are importing the Calendar component from the react-calendar package and using the useState hook to manage the state of the selected date. State manages the variables binded to a react component.

If you're not familiar with React hooks, you can find out more about them here

We then render the Calendar component with the onChange and value props to enable date selection and update the selected date state.

This is just a basic example of how to use React Calendar, and that you can definitely customize it to suit your needs by passing additional props and styles to the Calendar component as needed.

Advanced Usage

Once you've gotten the hang of things mentioned above in the basic usage section, you might be interested in getting more advanced with React Calendar.

Thankfully, React Calendar provides many props and options for customization. Here are some common props that you can use to customize your calendar:

Info

Again, please keep in mind that there are many more available props to use.

You can find a list of all of the available props here

Props

Props are the arguments passed to a react component. Props determine the behavior of a component.

  • value : sets the selected date.
  • onChange : a function that is called when the date selection changes.
  • minDate and maxDate : sets the minimum and maximum selectable dates.
  • calendarType : sets the calendar type (e.g., US or ISO 8601).
  • showNavigation : shows or hides the navigation buttons.
  • tileClassName : a function that is called for each tile to set the class name.
  • tileContent : a function that is called for each tile to set the content.

Styling

If you want to use default Calendar styling to build upon its existing syles, you can import React-Calendar's styles by importing Calendar.css

import 'react-calendar/dist/Calendar.css';

Notes and warnings

In the documentation, you will see a series of indicator messages with different meanings. The messages will be as follows:

Danger

Specifies actions that may cause an error or will cause the application to crash.

Warning

Specifies content that must be read before proceeding, so please pay attention!

Info

Indicates additional information or tips.

Success

Indicates you successfully completed a section or task, good job!

Conclusion

As shown in the diagram below react calendar has styles and event listeners that can be attached to it. Furthermore, React Calendar is a dependency of React used for front-end web development.

graph LR
  A[React] -->| Framework | B[Frontend];
  C[React Caledar] -->| Package | A[React]
  D[Event Listeners] --> | Attached | C
  E[Styles] --> C

We hope you find our React Calendar documentation helpful! If you have any questions or feedback, please do not hesitate to contact us.

Contributors

Jack Boeri - jboeri@my.bcit.ca

Paarth Dhammi - pdhammi@my.bcit.ca

Happy coding! 😄