How to create Calendar in ReactJS ?
Last Updated :
26 Jul, 2024
Creating a calendar in React JS can help in React projects like to-do lists, e-commerce sites, Ticket booking sites, and many more apps. It visualizes the day, month, and year data and makes an interacting User interface.
Prerequisites
To create a calendar in React JS we will be using these approaches
Steps to create React Application
Step 1: You can create a new ReactJs project using the below command:
npx create-react-app gfg
Project Structure

Approach 1: Using @natscale/react-calendar
we are going to create a very simple calendar without any styling. So for this, we are going to install a new npm package. Run the below code in your terminal to install the package.
npm i @natscale/react-calendar
The updated dependencies in package.json will look like
{
"dependencies": {
"@natscale/react-calendar": "^0.0.0-beta.26",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
}
}
Example: Import and use the calender component from the installed library with useState variable to store values.
JavaScript
// Filename - App.js
import React, { useState, useCallback } from "react";
import { Calendar } from "@natscale/react-calendar";
export default function CalendarGfg() {
const [value, setValue] = useState();
const onChange = useCallback(
(value) => {
setValue(value);
},
[setValue]
);
return (
<div>
<h1>Calendar - GeeksforGeeks</h1>
<Calendar value={value} onChange={onChange} />
</div>
);
}
Steps to run the application: Run the below command in the terminal to run the app.
npm start
Output: This output will be visible on the http://localhost:3000/ on the browser window.
Approach 2: Using react-calendar
Using React-calender we can create a calender with some basic stylings. Run below command to install the react-calender package.
npm i react-calendar
The updated dependencies in package.json will look like
{
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-calendar": "^4.6.1",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
}
}
Example: Create a Calender with importing some basic styling provided by the library.
JavaScript
import React, { useState } from 'react';
import Calendar from 'react-calendar';
import 'react-calendar/dist/Calendar.css';
export default function CalendarGfg() {
const [value, onChange] = useState(new Date());
return (
<div>
<h1>Calendar - GeeksforGeeks</h1>
<Calendar
onChange={onChange}
value={value}
/>
</div>
);
}
Steps to run the application: Run the below command in the terminal to run the app.
npm start
Output: This output will be visible on the http://localhost:3000/ on the browser window.
Similar Reads
How to create components in ReactJS ? Components in React JS is are the core of building React applications. Components are the building blocks that contains UI elements and logic, making the development process easier and reusable. In this article we will see how we can create components in React JS. Table of Content React Functional C
3 min read
How to create Date Picker in ReactJS? Date pickers provide a simple way to select a single value from a pre-determined set. Material UI for React has this component available for us and it is very easy to integrate. We can create a Date Picker in ReactJS using the following approach:Creating React Application And Installing Module:Step
2 min read
How to Validate a Date in ReactJS? Validating input Date in react ensures the correct date input. The valid date input is commonly used in case of calculating days, getting DOB for user data, and other operations etc.Prerequisites:React JSNode JS and NPMApproachTo validate a date in React we will use the validator npm package. Take t
2 min read
How to create Time Picker in ReactJS ? Time pickers provide a simple way to select a single value from a pre-determined set. Material UI for React has this component available for us and it is very easy to integrate. We can create a Time Picker in ReactJS using the following approach:Creating React Application And Installing Module:Step
2 min read
How to Create Countdown Timer in React JS React timers are very common UI components that are widely used in various applications and websites to visually display the remaining time for a specific activity or event. React timers are mostly used to highlight the commencement or conclusion of events or offers on commercial websites.This tutor
8 min read
How to add Analog Clock in ReactJS ? In this article, we are going to learn how we can add Analog Clock in ReactJs. React is a free and open-source front-end JavaScript library for building user interfaces or UI components. It is maintained by Facebook and a community of individual developers and companies.Approach to create Analog Clo
2 min read
How to create Popup box in React JS ? Popup boxes, also known as modal or dialog boxes, are common UI elements used to display additional content or interactions on top of the main page. Creating a popup box in React can be achieved using various approaches, including libraries or custom implementations. We will use the Reactjs-popup li
2 min read
How to add Calendar in Next.js ? Adding a calendar to a Next.js application enhances scheduling and event management. We can just install and use the available npm package. In this article, we are going to learn how we can add a calendar loader in NextJS.ApproachTo add our calendar we are going to use the react-calendar package. Th
2 min read
ReactJS UI Ant Design Calendar Component Ant Design, commonly referred to as AntD, is a widely used UI framework for building React applications. One of the components is the Calendar component which is a versatile and highly customizable date display tool that helps developers easily integrate date-based functionalities in their applicati
3 min read
How to create A Dynamic Calendar in HTML CSS & JavaScript? In this article, we will see how we can create A Dynamic Calendar with the help of HTML CSS & JavaScript. We will be designing and implementing a straightforward yet effective dynamic calendar, offering seamless month navigation and quick access to the current month. With a visually appealing de
10 min read