Shapes in Angular Skeleton component

27 Apr 20244 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 { Component } from '@angular/core';

@Component({
    selector: 'my-app',
    template: `<ejs-skeleton shape= 'Circle' width= "48px"></ejs-skeleton>`
})

export class AppComponent { }

Square skeleton shape

import { Component } from '@angular/core';

@Component({
    selector: 'my-app',
    template: `<ejs-skeleton shape= 'Square' width= "48px"></ejs-skeleton>`
})

export class AppComponent { }

Rectangle skeleton shape

import { Component } from '@angular/core';

@Component({
    selector: 'my-app',
    template: `<ejs-skeleton shape= 'Rectangle' width= "50px" height="25px"></ejs-skeleton>`
})

export class AppComponent { }

Text skeleton shape

import { Component } from '@angular/core';

@Component({
    selector: 'my-app',
    template: `<ejs-skeleton shape= 'Text' width= "50%" height="15px"></ejs-skeleton>`
})

export class AppComponent { }

Below example demonstrates the above functionalities of a Skeleton component.

import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { SkeletonModule } from '@syncfusion/ej2-angular-notifications'




import { Component } from '@angular/core';

@Component({
imports: [
         
        SkeletonModule
    ],


standalone: true,
    selector: 'my-app',
    template: `<div id="skeletonCard">
        <div class='cardProfile'>
            <ejs-skeleton id="cardProfile" shape="Circle" width="60px"></ejs-skeleton>
        </div>
        <div class="cardinfo">
            <ejs-skeleton id="text1" width="30%" height='15px'></ejs-skeleton><br/>
            <ejs-skeleton id="text2" width="15%" height='15px'></ejs-skeleton>
        </div>
        <div class="cardContent">
            <ejs-skeleton id="cardImage" shape="Rectangle" width="100%" height='150px'></ejs-skeleton>
        </div>
        <div class="cardoptions">
            <ejs-skeleton id="rightOption" shape="Rectangle" width="20%" height='32px'></ejs-skeleton>
            <ejs-skeleton id="leftOption" shape="Rectangle" width="20%" height='32px'></ejs-skeleton>
        </div>
    </div>`
    })

export class AppComponent {}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
/* 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;
}