Shapes in Angular Skeleton component

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

@Component({
    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 { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { SkeletonModule } from '@syncfusion/ej2-angular-notifications';

import { AppComponent } from './app.component';

/**
 * Module
 */
@NgModule({
    imports: [
        BrowserModule, 
        SkeletonModule
    ],
    declarations: [AppComponent ],
    bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

import 'zone.js';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
/* 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;
}