Skeletons

Text block

A paragraph placeholder. The short final line is what sells it as text; the per-line stagger stops the block from blinking as one slab.

  • paragraph
  • stagger

Preview

Usage

<SkeletonText lines={4} animation="shimmer" stagger={90} />
import { Skeleton, type SkeletonAnimation } from "./Skeleton";
import { cn } from "@/lib/cn";

export interface SkeletonTextProps {
  lines?: number;
  animation?: SkeletonAnimation;
  /** Width of the final line, so the block reads like a paragraph. */
  lastLineWidth?: string;
  /** ms added per line, producing a top-to-bottom ripple. */
  stagger?: number;
  gap?: number;
  lineHeight?: number;
  className?: string;
}

export function SkeletonText({
  lines = 3,
  animation = "shimmer",
  lastLineWidth = "62%",
  stagger = 90,
  gap = 10,
  lineHeight = 10,
  className,
}: SkeletonTextProps) {
  return (
    <div className={cn("w-full", className)} style={{ display: "grid", gap }}>
      {Array.from({ length: lines }, (_, i) => (
        <Skeleton
          key={i}
          animation={animation}
          delay={i * stagger}
          height={lineHeight}
          width={i === lines - 1 && lines > 1 ? lastLineWidth : "100%"}
        />
      ))}
    </div>
  );
}

export default SkeletonText;