Shapes in EJ2 TypeScript Skeleton control

29 Aug 20235 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 control supports the following content shapes:

Circle skeleton shape

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');

Square skeleton shape

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');

Rectangle skeleton shape

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');

Text skeleton shape

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="https://cdn.syncfusion.com/ej2/25.1.35/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/25.1.35/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>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></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>