Shapes in React Skeleton component

29 Aug 20237 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

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

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

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

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

function App() {

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

Below example demonstrates the above functionalities of a Skeleton component.

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'));
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'));
/* Represents the styles for loader */
#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;
}