Skeleton

A placeholder while content loads. In the look of the app's style.

Data DisplayExperimental

Usage

import { Component, ViewEncapsulation } from '@angular/core';import { ScSkeleton } from '@semantic-components/ui';
@Component({  selector: 'app-skeleton-usage-demo',  imports: [ScSkeleton],  template: `    <div class="flex items-center gap-4">      <div scSkeleton class="size-12 rounded-full"></div>      <div class="space-y-2">        <div scSkeleton class="h-4 w-[250px]"></div>        <div scSkeleton class="h-4 w-[200px]"></div>      </div>    </div>  `,  host: { class: 'flex w-full justify-center' },  encapsulation: ViewEncapsulation.None,})export class SkeletonUsageDemo {}

Anatomy

A directive on your div; its size and shape are yours (h-4 w-48, rounded-full…), its look the style's.

import { ScSkeleton } from '@semantic-components/ui';
<div scSkeleton class="h-4 w-48"></div>

Accessibility

  • A skeleton is empty and silent. Say the region is loading with aria-busy="true" on it, and remove it when the content arrives.
  • It stops pulsing when the user asks for less motion (prefers-reduced-motion).

Examples

Avatar

import { Component, ViewEncapsulation } from '@angular/core';import { ScSkeleton } from '@semantic-components/ui';
/** A person while they load: a round picture and two lines. */@Component({  selector: 'app-avatar-skeleton-demo',  imports: [ScSkeleton],  template: `    <div class="flex w-fit items-center gap-4">      <div scSkeleton class="size-10 shrink-0 rounded-full"></div>

Card

import { Component, ViewEncapsulation } from '@angular/core';import {  ScCard,  ScCardBody,  ScCardHeader,  ScSkeleton,} from '@semantic-components/ui';
/** A card while its content loads: in the card’s own parts. */@Component({

Text

import { Component, ViewEncapsulation } from '@angular/core';import { ScSkeleton } from '@semantic-components/ui';
/** A paragraph: full lines, the last one shorter. */@Component({  selector: 'app-text-skeleton-demo',  imports: [ScSkeleton],  template: `    <div class="flex w-full max-w-xs flex-col gap-2">      <div scSkeleton class="h-4 w-full"></div>

Form

import { Component, ViewEncapsulation } from '@angular/core';import { ScSkeleton } from '@semantic-components/ui';
/** A form: each field’s label and input, then its button. */@Component({  selector: 'app-form-skeleton-demo',  imports: [ScSkeleton],  template: `    <div class="flex w-full max-w-xs flex-col gap-7">      <div class="flex flex-col gap-3">

Table

import { Component, ViewEncapsulation } from '@angular/core';import { ScSkeleton } from '@semantic-components/ui';
/** Rows of a table: a wide column, then two narrow ones. */@Component({  selector: 'app-table-skeleton-demo',  imports: [ScSkeleton],  template: `    <div class="flex w-full max-w-sm flex-col gap-2">      @for (row of rows; track row) {

RTL

import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation } from '@angular/core';import { ScSkeleton } from '@semantic-components/ui';
/** In a right-to-left page: the picture at the right, the lines from the right. */@Component({  selector: 'app-rtl-skeleton-demo',  imports: [Dir, ScSkeleton],  template: `    <div dir="rtl" lang="ar">

API reference

Each part takes class, merged over the style (cn: a later class wins).

PartSelectorDescription
ScSkeletondiv[scSkeleton] The placeholder: a pulsing muted block in the style's look, still with reduced motion. Size and shape in your class.