import { Component } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { SKELETON_COMPONENTS } from '../../../../../ui-essentials/src/lib/components/feedback/skeleton-loader/skeleton-loader.component'; @Component({ selector: 'ui-skeleton-loader-demo', standalone: true, imports: [CommonModule, FormsModule, ...SKELETON_COMPONENTS], template: `

Skeleton Loader Demo

Skeleton loaders provide visual placeholders while content is loading, improving perceived performance and user experience.

Sizes

@for (size of sizes; track size) {
}

Shapes

@for (shape of shapes; track shape) {
}

Animation Types

@for (animation of animations; track animation) {
}

Width Variants

@for (width of widths; track width) {
}

Pre-built Components

Text Block

Profile

Card

Article

Table Rows

@for (row of [1,2,3]; track row) { }

Skeleton Groups

Vertical Group

Horizontal Group

Grid Group

Interactive Loading Simulation

@if (isLoading) { } @else {

Sample Article Title

Published on January 15, 2024 by John Doe

Sample image

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

}

Best Practices

  • Match Content Structure: Skeleton shapes should closely match the final content layout
  • Use Appropriate Animations: Shimmer for fast loading, pulse for slower operations
  • Respect Accessibility: Include proper ARIA labels and roles
  • Consider Performance: Reduce animation complexity on low-performance devices
  • Maintain Consistency: Use consistent skeleton patterns across your application

Code Examples

Basic Skeleton

<ui-skeleton-loader shape="text" size="md"></ui-skeleton-loader>

Profile Skeleton

<ui-skeleton-profile avatarSize="lg"></ui-skeleton-profile>

Custom Group

<ui-skeleton-group variant="horizontal">
  <ui-skeleton-loader shape="avatar" size="sm"></ui-skeleton-loader>
  <ui-skeleton-loader shape="text" width="w-75"></ui-skeleton-loader>
</ui-skeleton-group>
`, styleUrl: './skeleton-loader-demo.component.scss' }) export class SkeletonLoaderDemoComponent { sizes = ['xs', 'sm', 'md', 'lg', 'xl'] as const; shapes = ['text', 'heading', 'avatar', 'card', 'button', 'image', 'circle', 'rounded', 'square'] as const; animations = ['shimmer', 'pulse', 'wave'] as const; widths = ['w-25', 'w-50', 'w-75', 'w-full'] as const; isLoading = true; selectedAnimation = 'shimmer' as any; toggleLoading(): void { this.isLoading = !this.isLoading; } onAnimationChange(): void { // Force re-render by toggling loading state if (this.isLoading) { this.isLoading = false; setTimeout(() => { this.isLoading = true; }, 50); } } }