Skeleton

Loading state placeholder with pulse animation

The Skeleton component provides animated placeholder shapes that indicate content is loading. Use skeletons to reduce perceived load time and prevent layout shift.

Installation

bash
shellui add skeleton

Basic Usage

<Skeleton Class="h-4 w-[250px]" />

The default styling applies animate-pulse rounded-md bg-muted for a smooth pulsing effect.

Variants

Variant="circle" rounds the shape fully, for avatars; Variant="text" gives a full-width line of text height. Size them with Class.

<div class="flex w-full max-w-sm items-center gap-4">
  <Skeleton Variant="circle" Class="h-12 w-12" />
  <div class="flex-1 space-y-2">
    <Skeleton Variant="text" />
    <Skeleton Variant="text" Class="w-2/3" />
  </div>
</div>

Text Skeleton

Simulate loading text with varying widths:

<div class="space-y-2">
  <Skeleton Class="h-4 w-[300px]" />
  <Skeleton Class="h-4 w-[250px]" />
  <Skeleton Class="h-4 w-[200px]" />
</div>

Card Skeleton

Match the layout of a card component:

<div class="flex flex-col space-y-3">
  <Skeleton Class="h-[200px] w-full rounded-xl" />
  <div class="space-y-2">
    <Skeleton Class="h-4 w-[250px]" />
    <Skeleton Class="h-4 w-[200px]" />
  </div>
</div>

Profile Skeleton

Simulate a user profile loading state:

<div class="flex items-center space-x-4">
  <Skeleton Class="h-12 w-12 rounded-full" />
  <div class="space-y-2">
    <Skeleton Class="h-4 w-[150px]" />
    <Skeleton Class="h-4 w-[100px]" />
  </div>
</div>

Table Skeleton

Placeholder for loading table rows:

<div class="space-y-3">
  <div class="flex space-x-4">
    <Skeleton Class="h-4 w-[100px]" />
    <Skeleton Class="h-4 w-[200px]" />
    <Skeleton Class="h-4 w-[80px]" />
  </div>
  @for (var i = 0; i < 5; i++)
  {
    <div class="flex space-x-4">
      <Skeleton Class="h-4 w-[100px]" />
      <Skeleton Class="h-4 w-[200px]" />
      <Skeleton Class="h-4 w-[80px]" />
    </div>
  }
</div>

Conditional Loading

Toggle between skeleton and real content:

Quarterly report

Revenue grew 12% quarter over quarter.

<Button Variant="ButtonVariant.Outline" OnClick="Reload">Reload</Button>

<div class="mt-4">
  @if (isLoading)
  {
    <div class="space-y-2">
      <Skeleton Class="h-8 w-[200px]" />
      <Skeleton Class="h-4 w-full" />
      <Skeleton Class="h-4 w-full" />
    </div>
  }
  else
  {
    <div>
      <h2>@title</h2>
      <p>@description</p>
    </div>
  }
</div>

@code {
    private bool isLoading = true;
    private string title = "Quarterly report";
    private string description = "Revenue grew 12% quarter over quarter.";

    protected override Task OnInitializedAsync() => Reload();

    private async Task Reload()
    {
        isLoading = true;
        await Task.Delay(1500);
        isLoading = false;
    }
}

API Reference

Property Type Default Description
Variant string "default" default, circle or text
ChildContent RenderFragment null Optional content inside the skeleton
Class string? null CSS classes for sizing and shape

Default CSS

The Skeleton renders with animate-pulse rounded-md bg-muted applied automatically. Override with the Class parameter.

Accessibility

The Skeleton component includes:

  • aria-hidden="true" to hide from screen readers
  • Use alongside aria-busy="true" on the loading container
  • No interactive elements within skeletons

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.