Skeleton

A soft placeholder while content loads.

Install

$ npx shadcn@latest add @nudgekit/skeleton

Or with no config: npx shadcn@latest add https://ui.nudgekit.app/r/skeleton.json

Usage

usage.tsx
import { Skeleton } from "@/components/ui/skeleton"

<Skeleton className="h-5 w-1/2" />
<Skeleton className="h-28 w-full rounded-xl" />

Do

  • Match the shape of the content that is coming.

Don't

  • Show skeletons for more than a moment.

Code

What the CLI writes into your project. It is yours to change.

components/ui/skeleton.tsx
import * as React from "react";

import { cn } from "@/lib/utils";

function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
  return (
    <div
      aria-hidden
      data-slot="skeleton"
      className={cn("animate-pulse rounded-md bg-surface ring-1 ring-inset ring-border motion-reduce:animate-none", className)}
      {...props}
    />
  );
}

export { Skeleton };