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 control supports the following content shapes:
import { Skeleton } from '@syncfusion/ej2-notifications';
// Initialize Skeleton control for circle shape
let circle: Skeleton = new Skeleton({
shape: 'Circle',
width: "48px"
});
// Render initialized Skeleton.
circle.appendTo('#circleSkeleton');
import { Skeleton } from '@syncfusion/ej2-notifications';
// Initialize Skeleton control for square shape
let square: Skeleton = new Skeleton({
shape: 'Square',
width: "48px"
});
// Render initialized Skeleton.
square.appendTo('#squareSkeleton');
import { Skeleton } from '@syncfusion/ej2-notifications';
// Initialize Skeleton control for rectangle shape
let rect: Skeleton = new Skeleton({
shape: "Rectangle",
height: '50px'
});
// Render initialized Skeleton.
rect.appendTo('#rectSkeleton');
import { Skeleton } from '@syncfusion/ej2-notifications';
// Initialize Skeleton control for text shape
let text: Skeleton = new Skeleton({
shape: "Text",
height: "15px"
})
// Render initialized Skeleton.
text.appendTo('#textSkeleton');
Below example demonstrates the above functionalities of a Skeleton control.
import { Skeleton } from '@syncfusion/ej2-notifications';
// Initialize Skeleton control for circle shape
let cardProfile: Skeleton = new Skeleton({shape: 'Circle', width: '60px', height: '60px'});
// Render initialized Skeleton.
cardProfile.appendTo('#cardProfile');
let text1: Skeleton = new Skeleton({width: '30%', height: '15px'});
text1.appendTo('#text1');
let text2: Skeleton = new Skeleton({width: '15%', height: '15px'});
text2.appendTo('#text2');
let cardImage: Skeleton = new Skeleton({shape: 'Rectangle', width: '100%', height: '150px'});
cardImage.appendTo('#cardImage');
let rightOption: Skeleton = new Skeleton({shape: 'Rectangle', width: '20%', height: '32px'});
rightOption.appendTo('#rightOption');
let leftOption: Skeleton = new Skeleton({shape: 'Rectangle', width: '20%', height: '32px'});
leftOption.appendTo('#leftOption');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Skeleton</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<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" />
<link href="styles.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>LOADING....</div>
<div id='container'>
<div id="skeletonCard" class="e-card" style="display: block">
<div class="cardProfile">
<div id="cardProfile"></div>
</div>
<div class="cardinfo">
<div id="text1"></div><br>
<div id="text2"></div>
</div>
<div class="cardContent">
<div id="cardImage"></div>
</div>
<div class="cardoptions">
<div id="rightOption"></div>
<div id="leftOption"></div>
</div>
</div>
</div>
</body>
</html>
#container {
visibility: hidden;
}
#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;
}