Skeletons

List rows

Rows with pseudo-random line widths, because a column of identical bars reads as a barcode rather than as names.

  • list
  • rows
  • feed

Preview

Usage

<SkeletonList rows={5} avatar action />
import { Skeleton, type SkeletonAnimation } from "./Skeleton";
import { cn } from "@/lib/cn";

export interface SkeletonListProps {
  rows?: number;
  animation?: SkeletonAnimation;
  avatar?: boolean;
  /** Trailing action placeholder on the right of each row. */
  action?: boolean;
  stagger?: number;
  className?: string;
}

export function SkeletonList({
  rows = 4,
  animation = "shimmer",
  avatar = true,
  action = false,
  stagger = 80,
  className,
}: SkeletonListProps) {
  return (
    <ul className={cn("divide-y divide-line", className)}>
      {Array.from({ length: rows }, (_, i) => (
        <li key={i} className="flex items-center gap-3 py-3">
          {avatar && (
            <Skeleton
              animation={animation}
              shape="circle"
              width={36}
              delay={i * stagger}
            />
          )}
          <div className="flex-1 space-y-2">
            <Skeleton
              animation={animation}
              height={10}
              width={`${52 + ((i * 13) % 34)}%`}
              delay={i * stagger}
            />
            <Skeleton
              animation={animation}
              height={8}
              width={`${28 + ((i * 17) % 26)}%`}
              delay={i * stagger + 60}
            />
          </div>
          {action && (
            <Skeleton
              animation={animation}
              shape="rect"
              width={64}
              height={26}
              delay={i * stagger + 120}
            />
          )}
        </li>
      ))}
    </ul>
  );
}

export default SkeletonList;