Search results

Shapes in JavaScript (ES5) Skeleton control

08 Feb 2023 / 1 minute 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 shapes,

Circle skeleton shape

Copied to clipboard
// Initialize Skeleton control for circle shape
var circle = new ej.notifications.Skeleton({
    shape: 'Circle',
    width: "48px"
});

// Render initialized Skeleton.
circle.appendTo('#circleSkeleton');

Square skeleton shape

Copied to clipboard
// Initialize Skeleton control for square shape
var square = new ej.notifications.Skeleton({
    shape: 'Square',
    width: "48px"
});

// Render initialized Skeleton.
square.appendTo('#squareSkeleton');

Rectangle skeleton shape

Copied to clipboard
// Initialize Skeleton control for rectangle shape
var rect = new ej.notifications.Skeleton({
    shape: "Rectangle",
    height: '50px'
});

// Render initialized Skeleton.
rect.appendTo('#rectSkeleton');

Text skeleton shape

Copied to clipboard
// Initialize Skeleton control for text shape
var text = new ej.notifications.Skeleton({
    shape: "Text",
    height: "15px"
})

// Render initialized Skeleton.
text.appendTo('#textSkeleton');

Below example demonstrates the above functionalities of a Skeleton control.

Source
Preview
index.js
index.html
styles.css
Copied to clipboard
ej.base.enableRipple(true);

// Initialize Skeleton control for circle shape
var cardProfile = new ej.notifications.Skeleton({shape: 'Circle', width: '60px', height: '60px'});

// Render initialized Skeleton.
cardProfile.appendTo('#cardProfile');

var text1 = new ej.notifications.Skeleton({width: '30%', height: '15px'});
text1.appendTo('#text1');

var text2 = new ej.notifications.Skeleton({width: '15%', height: '15px'});
text2.appendTo('#text2');

var cardImage = new ej.notifications.Skeleton({shape: 'Rectangle', width: '100%', height: '150px'});
cardImage.appendTo('#cardImage');

var rightOption = new ej.notifications.Skeleton({shape: 'Rectangle', width: '20%', height: '32px'});
rightOption.appendTo('#rightOption');

var leftOption = new ej.notifications.Skeleton({shape: 'Rectangle', width: '20%', height: '32px'});
leftOption.appendTo('#leftOption');
Copied to clipboard
<!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://cdn.syncfusion.com/ej2/20.4.48/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    
    <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>


<script>
var ele = document.getElementById('container');
if(ele) {
    ele.style.visibility = "visible";
 }   
        </script>
<script src="index.js" type="text/javascript"></script>
</body></html>
Copied to clipboard
#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;
}