Bloom Logo

Skeleton

Renders subtle animated pulse loading placeholders while data or media content is fetching.

importimport { Skeleton } from "@/components/ui/skeleton/skeleton";
$npx @bloomui-react/cli add skeleton
skeleton.tsx
"use client";

import * as React from "react";
import { designRadius } from "@/lib/design-system";
import { cn } from "@/lib/utils";

export interface SkeletonProps extends React.HTMLAttributes<HTMLDivElement> {
  variant?: "circle" | "rectangle" | "text";
  radius?: keyof typeof designRadius;
  animation?: "pulse" | "shimmer" | "none";
  isLoaded?: boolean;
}

const variantStyles = {
  circle: "rounded-full aspect-square",
  rectangle: "",
  text: "h-4 w-full rounded-md",
};

const Skeleton = React.forwardRef<HTMLDivElement, SkeletonProps>(
  (
    {
      className,
      variant = "rectangle",
      radius = "lg",
      animation = "pulse",
      isLoaded = false,
      children,
      ...props
    },
    ref,
  ) => {
    if (isLoaded) {
      return <>{children}</>;
    }

    return (
      <div
        ref={ref}
        role="status"
        aria-busy="true"
        aria-label="Loading..."
        className={cn(
          "bg-zinc-200 dark:bg-zinc-800 shrink-0 relative overflow-hidden",
          animation === "pulse" && "animate-pulse",
          variantStyles[variant],
          variant !== "circle" && designRadius[radius],
          className,
        )}
        {...props}
      >
        {animation === "shimmer" && (
          <div className="absolute inset-0 -translate-x-full animate-shimmer bg-gradient-to-r from-transparent via-white/80 dark:via-white/30 to-transparent pointer-events-none" />
        )}
        <span className="sr-only">Loading...</span>
      </div>
    );
  },
);

Skeleton.displayName = "Skeleton";

export { Skeleton };

Default

Standard skeleton card loading placeholder.

Loading...
Loading...
Loading...

Media Card Placeholder

Complex UI card skeleton preview structure.

p-4: anyborder: anyrounded-2xl: anyspace-y-3: anyvariant: anyrectangle: anyw-full: anyh-36: anyrounded-xl: anytext: anyw-4: anyh-4: anyh-3: any
Loading...
Loading...
Loading...
Loading...

Animation Switcher (Pulse vs Shimmer)

Switch between classic pulse animation (animation="pulse") and glowing gradient shimmer wave (animation="shimmer").

animation: pulse | shimmer | none
Pulse Animation
Loading...
Loading...
Shimmer Wave Animation
Loading...
Loading...
API Reference

Props — Skeleton

Supported properties for Skeleton.

PropTypeDefaultDescription
animation'pulse' | 'shimmer' | 'none''pulse'Animation effect switcher (pulse fade or shimmer gradient wave).
variant'circle' | 'rectangle' | 'text''rectangle'Shape layout of the loading placeholder.
isLoadedbooleanfalseWhen true, replaces skeleton with real children.