How to create Loading Screen in ReactJS ?
Last Updated :
26 Jul, 2024
Loading screen plays a major role in enhancing UX development. In this article, we are going to learn how we can create a Loading Screen in ReactJs. A loading screen is a picture shown by a computer program, often a video game, while the program is loading or initializing.
Prerequisites
Approach to create Loading Screen:
To create our loading screen we are going to use the react-loading package because it is powerful, lightweight, and fully customizable. After that, we will add different types of loading screens on our homepage using the installed package.
Steps to create React Application And Installing Module:
Step 1: You can create a new ReactJs project using the below command:
npx create-react-app gfg
IStep 2: Install the required package: Now we will install the react-loading package using the below command:
npm i react-loading
Project Structure:

The updated dependencies in package.json file 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-dom": "^18.2.0",
"react-loading": "^2.0.3",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
}
Example: In this example, we are going to add the react-loading on the homepage of our app using the package that we installed. For this, add the below content in the App.js file.
JavaScript
//App.js
import React from "react";
import ReactLoading from "react-loading";
export default function Loading() {
return (
<div>
<h2>Loading in ReactJs - GeeksforGeeks</h2>
<ReactLoading type="balls" color="#0000FF"
height={100} width={50} />
<ReactLoading type="bars" color="#0000FF"
height={100} width={50} />
<ReactLoading type="bubbles" color="#0000FF"
height={100} width={50} />
<ReactLoading type="cubes" color="#0000FF"
height={100} width={50} />
<ReactLoading type="cylon" color="#0000FF"
height={100} width={50} />
<ReactLoading type="spin" color="#0000FF"
height={100} width={50} />
<ReactLoading type="spokes" color="#0000FF"
height={100} width={50} />
<ReactLoading
type="spinningBubbles"
color="#0000FF"
height={100}
width={50}
/>
</div>
);
}
Explanation: In the above example first, we are importing the ReactLoading component from the react-loading package. After that, we are using our ReactLoading component to add different types of loading screens. We can set the type, color, height, and width of the loading screen.
Steps to run the application: Run the below command in the terminal to run the app.
npm start
Output:
Similar Reads
How to add Skeleton Loading in NextJS ? Skeleton Loading in Next.js provides a placeholder UI while content is loading, improving perceived performance and user experience. It visually represents loading elements, ensuring a smoother, more engaging application.ApproachTo add skeleton loading in nextjs application we are going to use the r
2 min read
How to create Tabs in ReactJS ? Tabs make it easy to explore and switch between different views. Material UI for React has this component available for us and it is very easy to integrate. We can use Tabs Component in ReactJS using the following approach.Prerequisites:NPM & Node.jsReact JSMaterial UIwe have these approaches to
4 min read
How to Add a Loading GIF in ReactJS? Loading indicators are essential in web applications to enhance user experience by providing visual feedback during asynchronous operations. They help users understand that a process is ongoing and prevent them from interacting with the application while it's loading. Approach Start by defining a st
3 min read
How To Create a Website in ReactJS? ReactJS is one of the most popular JavaScript libraries for building user interfaces. It allows you to create dynamic, reusable UI components and efficiently manage state and events. In this article, we'll walk through the steps to create a basic website using ReactJS.PrerequisitesNPM & Node.jsR
5 min read
How to create progress bar in React JS ? A progress bar shows the measure of progress of any task or activity. It is the graphical representation of progression. Material UI for React has this component available for us and is very easy to integrate. We can Create a straightforward Progress Bar in React JS using the following approach.Prer
2 min read
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 Handle Loading Between Page Changes in NextJS? To experience smooth transitions between the pages of your Next.js application, you can include a loading indicator that shows the progress of the page being loaded. This can be done by creating a custom spinner component and using it during page transitions. In this article, we will create a custom
4 min read
How To Create A Multi-Page Website Using ReactJS? Multi-page website using ReactJS is the core for building complex web applications that require multiple views or pages. Previously where each page reloads entirely, ReactJS allows you to navigate between different pages without reloading the whole page thanks to libraries like React Router.In this
4 min read
React Suite Loading Button React Suite is a popular front-end library with a set of React components that are designed for the middle platform and back-end products. The Button component is used to fire an action when the user clicks on it. In this article, we will be seeing React Suite Loading button. The loading button is
3 min read
How To Create a Delay Function in ReactJS ? Delay functions in programming allow for pausing code execution, giving deveÂlopers precise control over timing. These functions are essential for tasks such as content display, animations, synchronization, and managing asynchronous operations. In this article, we will discuss how can we create a d
3 min read