The Wayback Machine - https://web.archive.org/web/20240614060431/https://www.geeksforgeeks.org/how-to-use-skeleton-component-in-reactjs/
Open In App

How to use Skeleton Component in React JS ?

Last Updated : 14 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

When data is not yet loaded, a Skeleton Component serves as a placeholder preview for the user. Material UI for React provides an easily integratable version of this component, and in React JS, the following approach can be employed to utilize the Skeleton Component.

Prerequisites:

Steps to Create React Application And Installing Module:

Step 1: Create a React application using the following command:

npx create-react-app foldername

Step 2: After creating your project folder i.e. foldername, move to it using the following command:

cd foldername

Step 3: After creating the ReactJS application, Install the material-ui module using the following command:

npm install @mui/material

Project Structure:

Project Structure

Example 1: In this example, we will create a Skeleton component for a text, rectangular and circular variants. Please update App.js like below.

Javascript




import { Skeleton } from "@mui/material";
import React from "react";
 
export default function App() {
    return (
        <div style={{
            display: "block",
            padding: 30
        }}>
            <h4>
                How to use Skeleton Component in ReactJS?
            </h4>
            TEXT VARIANT: <Skeleton variant="text" width={200} />
            <br />
            RECTANGULAR VARIANT: <Skeleton
                variant="rect"
                width={110}
                height={220}
            />{" "}
            <br />
            CIRCLE VARIANT:
            <Skeleton variant="circle"
                width={50} height={50} />{" "}
            <br />
        </div>
    );
}


Step to Run Application: Run the application using the following command from the root directory of the project:

npm start

Output: Now open your browser and go to http://localhost:3000

Example 2: In this example, we will create Skeleton components having different animations. Please update App.js like the below.

Javascript




import { Skeleton } from "@mui/material";
import React from "react";
 
export default function App() {
    return (
        <div style={{ display: "block", padding: 30 }}>
            <h4>
                How to use Skeleton
                Component in ReactJS?
            </h4>
            Default animantion: <Skeleton />
            Wave animantion: <Skeleton animation="wave" />
            No animantion: <Skeleton animation={false} />
        </div>
    );
}


Steps to Run the application:

npm start

Output:

Output



Similar Reads

React.js Blueprint skeleton Component CSS
BlueprintJS is a React-based UI toolkit for the web. This library is very optimized and popular for building interfaces that are complex data-dense for desktop applications. In this article, we are going to discuss React.js BluePrint skeleton CSS Component. Skeleton Component provides a way for users to provide a loading state which indicates the s
3 min read
ReactJS UI Ant Design Skeleton Component
Ant Design Library has this component pre-built, and it is very easy to integrate as well. Skeleton Component is used whenever the data is not loaded. It is used to provide a placeholder while the content is loaded. We can use the following approach in ReactJS to use the Ant Design Skeleton Component. Skeleton Props: active: It is used to show the
3 min read
ReactJS Blueprint Skeleton Component
BlueprintJS is a React-based UI toolkit for the web. This library is very optimized and popular for building interfaces that are complex data-dense for desktop applications. Skeleton Component provides a way for users to provide a loading state which indicates the shape of your yet-to-load content. We can use the following approach in ReactJS to us
2 min read
Angular PrimeNG Skeleton Component
Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will know how to use Skeleton Component in Angular PrimeNG. We will also learn about the properties along with their syntaxes that
4 min read
React MUI Skeleton Feedback
React Material UI is an open-source library for the React User Interface components that implement Google's Material Design. It provides a wide range collection of prebuilt, reusable, responsive components which requires less coding and are ready to use for production implementation. It includes beautifully designed components that can be easily cu
3 min read
How to Create Skeleton Loading in React Native ?
React Native is a popular framework for cross-platform mobile app development. In this ​article we are going to create a skeleton loading effect in React Native, visually indicating content loading to inform users while data is fetched. In mobile app development, it's crucial to ensure a smooth user experience. However, network delays or fetching l
3 min read
Angular PrimeNG Skeleton List
Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will know how to use Skeleton List in Angular PrimeNG. We will also learn about the properties along with their syntaxes that will
4 min read
Angular PrimeNG Skeleton Size
Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will know how to use Skeleton Size in Angular PrimeNG. We will also learn about the properties along with their syntaxes that will
3 min read
How to Create Skeleton Screen Loading Effect using CSS ?
The skeleton screens are used to indicate that the content is loading. They are also called splash screens. This is a part of the modern design trend. The skeleton screens are better than the loading spinners in some cases. It is used by many big companies like Facebook, Google, etc. HTML Code: In this section, we will create a basic structure of l
4 min read
Angular PrimeNG Skeleton Styling
Angular Prime NG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. This article will show how to use Skeleton Component Styling in Angular Prime NG. The Skeleton component serves as a stand-in for the material to be
3 min read