Search results

Shapes in React Skeleton component

02 Feb 2023 / 2 minutes to read

The Skeleton control support various built-in shape variants to design layout of the page. You can use the shape property to create a preview of any layout.

The Skeleton component supports the following content shapes:

Circle skeleton shape

Copied to clipboard
import { SkeletonComponent } from '@syncfusion/ej2-react-notifications';
import * as React from "react";

function App() {
    return (
      <SkeletonComponent shape= 'Circle' width= "48px"></SkeletonComponent>
      );
}
export default App;

Square skeleton shape

Copied to clipboard
import { SkeletonComponent } from '@syncfusion/ej2-react-notifications';
import * as React from "react";

function App() {

  return (
    <SkeletonComponent shape= 'Square' width= "48px"></SkeletonComponent>);
}
export default App;

Rectangle skeleton shape

Copied to clipboard
import { SkeletonComponent } from '@syncfusion/ej2-react-notifications';
import * as React from "react";

function App() {

  return (
    <SkeletonComponent shape= 'Rectangle' width= "50px" height='32px'></SkeletonComponent>);
}
export default App;

Text skeleton shape

Copied to clipboard
import { SkeletonComponent } from '@syncfusion/ej2-react-notifications';
import * as React from "react";

function App() {

  return (
    <SkeletonComponent shape= 'Text' width= "15px"></SkeletonComponent>);
}
export default App;

Below example demonstrates the above functionalities of a Skeleton component.

Source
Preview
index.jsx
index.html
index.css
index.tsx
Copied to clipboard
import { SkeletonComponent } from '@syncfusion/ej2-react-notifications';
import * as React from "react";
import * as ReactDOM from 'react-dom';
function App() {
    return (<div>
        <div id="skeletonCard">
            <div className='cardProfile'>
                <SkeletonComponent id='cardProfile' shape='Circle' width="60px"></SkeletonComponent>
            </div>
            <div className="cardinfo">
                <SkeletonComponent id="text1" width="30%" height='15px'></SkeletonComponent><br />
                <SkeletonComponent id="text2" width="15%" height='15px'></SkeletonComponent>
            </div>
            <div className="cardContent">
                <SkeletonComponent id="cardImage" shape="Rectangle" width="100%" height='150px'></SkeletonComponent>
            </div>
            <div className="cardoptions">
                <SkeletonComponent id="rightOption" shape="Rectangle" width="20%" height='32px'></SkeletonComponent>
                <SkeletonComponent id="leftOption" shape="Rectangle" width="20%" height='32px'></SkeletonComponent>
            </div>
        </div>
      </div>);
}
export default App;
ReactDOM.render(<App />, document.getElementById('element'));
Copied to clipboard
<!DOCTYPE html>
<html lang="en">

<head>
            
    <title>Essential JS 2 React Skeleton Sample</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="//cdn.syncfusion.com/ej2/20.4.48/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/20.4.48/ej2-notifications/styles/material.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
    <link rel="stylesheet" href="index.css" />
</head>

<body>
    <div id='element'>
        <div id='loader'>Loading....</div></div>
</body>
</html>
Copied to clipboard
#loader {
	color: #008cff;
	height: 40px;
	left: 45%;
	position: absolute;
	top: 45%;
	width: 30%;
}

#skeletonCard {
	padding: 10px;
	line-height: inherit;
	height: 330px;
}

#skeletonCard .cardProfile {
	float: left;
	margin-right: 15px;
}

#skeletonCard .cardinfo {
	margin-top: 10px;
	overflow: hidden;
}

#skeletonCard .cardContent {
	margin: 20px 0px 20px;
}

#skeletonCard .cardoptions {
	display: flex;
	justify-content: space-between;
}
Copied to clipboard
import { SkeletonComponent } from '@syncfusion/ej2-react-notifications';
import * as React from "react";
import * as ReactDOM from 'react-dom';

function App() {

    return (
      <div>
        <div id="skeletonCard">
            <div className='cardProfile'>
                <SkeletonComponent id='cardProfile' shape= 'Circle' width= "60px"></SkeletonComponent>
            </div>
            <div className="cardinfo">
                <SkeletonComponent id="text1" width="30%" height='15px'></SkeletonComponent><br/>
                <SkeletonComponent id="text2" width="15%" height='15px'></SkeletonComponent>
            </div>
            <div className="cardContent">
                <SkeletonComponent id="cardImage" shape="Rectangle" width="100%" height='150px'></SkeletonComponent>
            </div>
            <div className="cardoptions">
                <SkeletonComponent id="rightOption" shape="Rectangle" width="20%" height='32px'></SkeletonComponent>
                <SkeletonComponent id="leftOption" shape="Rectangle" width="20%" height='32px'></SkeletonComponent>
            </div>
        </div>
      </div>);
}
export default App;
ReactDOM.render(<App />, document.getElementById('element'));