Skip to content
caliper ui docs

Components

Skeleton

A placeholder with the shape of the content it stands in for.

Free
pnpm dlx shadcn@latest add @caliper/skeleton

Lisbon studio

Loading people from the directory…

Mara Chen

Design lead · Lisbon

Kofi Mensah

Engineering · Accra

Ines Carvalho

Support · Porto

Installs components/ui/skeleton.tsxDepends on none beyond ReactMotion none in component source

When to use

Use it for

  • Content loads in a known layout, such as a profile card or a list row.
  • You want to avoid layout shift when the real content arrives.

Skip it when

  • The wait is short and unpredictable; a spinner is calmer.
  • Progress can be measured; use a progress bar.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/skeleton

Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage

This is the code behind the preview above.

example.tsx
import { useEffect, useState, type ReactNode } from "react"
import { Avatar } from "@/components/ui/avatar"
import { Button } from "@/components/ui/button"
import { cn } from "@/components/ui/lib/cn"
import { Skeleton } from "@/components/ui/skeleton"

function Panel({ title, context, action, className, children }: { title: string; context: string; action?: ReactNode; className?: string; children: ReactNode }) {
  return (
    <section className={cn("grid w-full max-w-md gap-5 rounded-overlay border border-border bg-background p-6 shadow-resting", className)}>
      <div className="flex items-start justify-between gap-3">
        <div className="grid min-w-0 gap-1">
          <p className="font-medium">{title}</p>
          <p className="text-sm text-muted-foreground">{context}</p>
        </div>
        {action}
      </div>
      {children}
    </section>
  );
}

const team = [
  { name: "Mara Chen", role: "Design lead · Lisbon" },
  { name: "Kofi Mensah", role: "Engineering · Accra" },
  { name: "Ines Carvalho", role: "Support · Porto" },
];

export function ProfileLoading() {
  const [loading, setLoading] = useState(true);
  useEffect(() => {
    if (!loading) return;
    const timer = setTimeout(() => setLoading(false), 2400);
    return () => clearTimeout(timer);
  }, [loading]);
  return (
    <Panel
      title="Lisbon studio"
      context={loading ? "Loading people from the directory…" : "3 people · synced just now"}
      action={<Button variant="secondary" size="sm" disabled={loading} onClick={() => setLoading(true)}>Reload</Button>}
    >
      <div className="grid gap-4">
        {team.map((person) => (
          <Skeleton key={person.name} label={`Loading ${person.name}`} avatar lines={2} loading={loading}>
            <div className="flex items-center gap-3">
              <Avatar name={person.name} className="size-8" />
              <div className="min-w-0">
                <p className="text-sm font-medium">{person.name}</p>
                <p className="text-xs text-muted-foreground">{person.role}</p>
              </div>
            </div>
          </Skeleton>
        ))}
      </div>
    </Panel>
  );
}

API reference

Skeleton

component

Also accepts the native props of its root element and a ref.

PropTypeDefault
labelstring"Loading content"
linesnumber3
avatarbooleanfalse
loadingbooleantrue
childrenReactNode—

Accessibility

It exposes status semantics, with aria-busy and aria-label kept in step with state. Changes that matter are announced through a live region.

No custom key handling; Tab and the native activation keys do the work.

Motion

It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.

All Feedback examples