Malay Patel

Skeleton

Component

About

A skeleton measured from the real layout: one bar per wrapped line of text, a box for every image and control, one shimmer across them all, and a top-to-bottom reveal when the content arrives. Free component from uibrik (uibrik.com).

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Skeleton to your project and fits it to your theme.

Code

How Skeleton is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { Skeleton } from "@/components/ui/skeleton";
import { useEffect, useState } from "react";

// Portraits from Unsplash, self-hosted: unsplash.com/photos/IF9TK5Uy-KI,
// unsplash.com/photos/UJbqowk5fso, unsplash.com/photos/hSKBleRfj5A
const PEOPLE = [
  {
    name: "Amara Okafor",
    handle: "@amara",
    avatar: "https://cdn.21st.dev/assets/mirror/59/5975d464eb7ebfcf7153a0384985cc8a201c5a9f24dfc70522213bff1fe827f2.webp",
    time: "2m",
    text: "Shipped the new billing flow. Checkout is down to two screens and the drop-off between them fell by a third.",
    stats: ["128", "24", "6"],
  },
  {
    name: "Jonas Weber",
    handle: "@jonasw",
    avatar: "https://cdn.21st.dev/assets/mirror/88/884e4f46575cef2a1523d021437d056d9ff4d3a446bc79938be18642936d1c64.webp",
    time: "18m",
    text: "Benchmarks for the edge cache are in: p95 dropped from 412 ms to 96 ms across all regions.",
    stats: ["86", "12", "3"],
  },
  {
    name: "Priya Raman",
    handle: "@priya",
    avatar: "https://cdn.21st.dev/assets/mirror/f9/f950df434342276d91e7190484d82d93970ffae71d2624819f79571818a8ba13.webp",
    time: "1h",
    text: "Design review at 3. Bring the empty states and the new onboarding checklist.",
    stats: ["41", "9", "2"],
  },
];

const BARS = [38, 52, 44, 68, 60, 82, 74, 90, 66, 78, 96, 88];

const {
  loading,
  cycle,
  ...props
} = {
  loading: true,
  cycle: true,
  shimmerDuration: 2.2,
  reveal: 0.5,
  radius: 6,
};

export default function Demo() {
  const [auto, setAuto] = useState(true);
  useEffect(() => {
    if (!cycle) return;
    const id = setTimeout(() => setAuto((a) => !a), auto ? 2400 : 3600);
    return () => clearTimeout(id);
  }, [cycle, auto]);
  const isLoading = cycle ? auto : loading;

  return (
    <div className="flex min-h-screen w-full items-center justify-center px-4 py-8">
      <div className="flex w-full max-w-[460px] flex-col gap-3">
        <div className="rounded-3xl bg-background p-5 shadow-[inset_0_0_0_1px_var(--border)]">
          <Skeleton {...props} loading={isLoading}>
            <div className="flex items-baseline justify-between">
              <span className="text-sm text-muted-foreground">
                Weekly active users
              </span>
              <span className="text-[13px] text-emerald-600 dark:text-emerald-400">
                +12.4%
              </span>
            </div>
            <div className="mt-1 text-2xl font-medium tabular-nums">48,209</div>
            <div
              data-skeleton
              className="mt-4 flex h-16 items-end gap-1.5 rounded-lg"
            >
              {BARS.map((h, i) => (
                <span
                  key={i}
                  className="flex-1 rounded-[3px] bg-foreground/80"
                  style={{
                    height: `${h}%`,
                    opacity: 0.35 + (i / BARS.length) * 0.65,
                  }}
                />
              ))}
            </div>
          </Skeleton>
        </div>
        {PEOPLE.map((p) => (
          <div
            key={p.handle}
            className="rounded-3xl bg-background p-4 shadow-[inset_0_0_0_1px_var(--border)]"
          >
            <Skeleton {...props} loading={isLoading} className="flex gap-3">
              {/* eslint-disable-next-line @next/next/no-img-element */}
              <img
                src={p.avatar}
                alt={p.name}
                width={40}
                height={40}
                decoding="async"
                className="size-10 shrink-0 rounded-full bg-muted object-cover"
              />
              <div className="min-w-0 flex-1">
                <div className="flex items-baseline gap-1.5 text-sm">
                  <span className="font-medium">{p.name}</span>
                  <span className="text-muted-foreground">{p.handle}</span>
                  <span className="ml-auto text-[13px] text-muted-foreground">
                    {p.time}
                  </span>
                </div>
                <p className="mt-1 text-sm leading-relaxed text-foreground/90">
                  {p.text}
                </p>
                <div className="mt-2.5 flex gap-4 text-[13px] text-muted-foreground">
                  <span>{p.stats[0]} likes</span>
                  <span>{p.stats[1]} replies</span>
                  <span>{p.stats[2]} shares</span>
                </div>
              </div>
            </Skeleton>
          </div>
        ))}
      </div>
    </div>
  );
}

Dependencies

More by Malay Patel

View all
  • Halftone

    Halftone

    48
  • Balloon Button

    Balloon Button

    33
  • Fold Toolbar

    Fold Toolbar

    31
  • Hold To Confirm

    Hold To Confirm

    14
  • Marquee

    Marquee

    9
  • Aurora

    Aurora

    6
  • Otp Input

    Otp Input

    5
  • Copy Button

    Copy Button

    4