Synertech Web/ui v0.57.5 Site Storybook

Documentation / Display & media

Skeleton

Server-compatible@synertech/uiOpen in Storybook

A placeholder block shown while loading, shaped like the content to come. Four shapes (text, circular, rectangular, rounded), two animations (pulse by default, wave) or none (none).

width and height take a number (in pixels) or any CSS value; a circular given only a width reuses it as its height. count repeats the block to mimic several lines. Each block carries aria-busy="true". No hooks: server-compatible.

Examples

Text lines

The default text shape takes the full width; count stacks several of them.

Open in a tab
import { Skeleton } from "@synertech/ui";

export function Basic() {
  return (
    <div className="max-w-md">
      <Skeleton count={3} />
    </div>
  );
}

Shapes

variant matches the corners to the content being replaced: avatar, image, card.

Open in a tab
import { Skeleton } from "@synertech/ui";

export function Variants() {
  return (
    <div className="flex items-center gap-4">
      <Skeleton variant="circular" width={48} />
      <Skeleton variant="rectangular" width={96} height={64} />
      <Skeleton variant="rounded" width={96} height={64} />
      <Skeleton variant="text" width="8rem" />
    </div>
  );
}

Animations

wave sweeps a shimmer across, none freezes the block (useful when the user prefers reduced motion).

Open in a tab
import { Skeleton } from "@synertech/ui";

export function Animations() {
  return (
    <div className="max-w-md space-y-3">
      <Skeleton animation="pulse" />
      <Skeleton animation="wave" />
      <Skeleton animation="none" />
    </div>
  );
}

Loading card

Shapes are composed to reproduce the exact silhouette of the final content.

Open in a tab
import { Skeleton } from "@synertech/ui";

export function CardPlaceholder() {
  return (
    <div className="flex max-w-sm gap-4 rounded-lg border border-gray-200 p-4 dark:border-gray-700">
      <Skeleton variant="circular" width={48} />
      <div className="flex-1 space-y-2">
        <Skeleton width="60%" />
        <Skeleton width="40%" height={12} />
        <Skeleton variant="rounded" height={80} className="mt-3" />
      </div>
    </div>
  );
}

Replaced by the content

The skeleton holds the profile’s place while the request runs, then makes way for it.

Open in a tab
import { useEffect, useState } from "react";
import { Avatar, Skeleton } from "@synertech/ui";

export function WhileLoading() {
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    const timer = setTimeout(() => setLoading(false), 2000);
    return () => clearTimeout(timer);
  }, []);

  return (
    <div className="flex items-center gap-3">
      {loading ? (
        <Skeleton variant="circular" width={40} />
      ) : (
        <Avatar fallback="CD" alt="Camille Durand" />
      )}
      {loading ? (
        <Skeleton width={140} />
      ) : (
        <span className="text-sm font-medium text-gray-900 dark:text-gray-100">Camille Durand</span>
      )}
    </div>
  );
}

API reference

Components

Skeleton

ComponentServer-compatible
import { Skeleton } from "@synertech/ui";

Props — SkeletonProps

PropTypeDefaultDescription
animation SkeletonAnimation "pulse"
count number 1
height string | number —
variant SkeletonVariant "text"
width string | number —

+ 279 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).

Types

type SkeletonAnimation = "pulse" | "wave" | "none"
type SkeletonVariant = "text" | "circular" | "rectangular" | "rounded"