Skip to content
Inspireca Design

Interactive Example · Loading

Skeleton loading placeholder

Grey shapes hold the place of content while it loads, in the same layout, so nothing jumps when the real content arrives.

Written by Inspireca Design (drafted with AI assistance)Updated Not yet reviewed by an editor

Try it

Use it with a mouse, by touch or with the keyboard. The controls below show its other states.

Loading profile
Preview controls

How it works

A skeleton is a rough outline of the content that is about to appear. Its job is to keep the page steady while something loads.

What moves

The shapes pulse gently between two opacities. When the content is ready it fades in over 200 milliseconds in exactly the same box. The card is given a fixed height, so the button under it does not move at any point. Press "Load again" to watch the change, or tick "Keep loading" to study the placeholder.

Match the real layout

The placeholder has a circle where the avatar will be and two bars where the two lines of text will be, at about their real widths. A skeleton that does not resemble the result causes the jump it was meant to prevent.

When to use it, and when not

  • Use it when content usually takes more than about half a second and you know its shape.
  • For very short waits, show nothing: a skeleton that flashes for a tenth of a second is worse than a brief pause.
  • For an action someone started, such as saving, use feedback on the button instead.
  • If loading can fail, design that state too. See Design every state of a component.

Accessibility notes

  • Says it is loading. The region has aria-busy while loading and contains the hidden text "Loading profile"; the grey shapes themselves are hidden from screen readers.
  • No flashing. The pulse is slow and low in contrast. Anything that flashes more than three times a second is a seizure risk (WCAG 2.2, 2.3.1).
  • Reduced motion: the shapes stay still and the content appears without a fade.
  • Motion that runs by itself for more than five seconds should be stoppable (2.2.2 Pause, Stop, Hide). A skeleton normally ends well before that; if your loading can run long, stop the pulse or show a message.

The code

This is the source of the preview above: React with Tailwind CSS classes (skeleton-loading.tsx). Colour names such as bg-primary and the ex- animation classes come from this site’s own stylesheet; replace them with your own.

"use client";

import { useEffect, useState } from "react";
import { RotateCw } from "lucide-react";
import type { DemoProps } from "@/lib/examples/keys";

/**
 * Grey shapes stand in for content while it loads, in the same layout, so nothing jumps when
 * the content arrives. The shapes pulse gently; with reduced motion they stay still.
 */
export default function SkeletonLoading({ values }: DemoProps) {
  const keepLoading = values.loading === true;
  const [round, setRound] = useState(0);
  const [done, setDone] = useState(false);

  useEffect(() => {
    const timer = window.setTimeout(() => setDone(true), 1600);
    return () => window.clearTimeout(timer);
  }, [round]);

  const loading = keepLoading || !done;
  const bone = "rounded-md bg-surface-strong animate-pulse motion-reduce:animate-none";

  return (
    <div className="w-full max-w-xs">
      {/* aria-busy tells assistive technology the region is still changing. */}
      <div aria-busy={loading} className="flex h-[76px] items-center gap-4 rounded-2xl border border-border bg-background p-4 text-left">
        {loading ? (
          <>
            <span className="sr-only">Loading profile</span>
            <span aria-hidden className={`size-11 shrink-0 rounded-full ${bone}`} />
            <span aria-hidden className="flex-1 space-y-2.5">
              <span className={`block h-3.5 w-2/3 ${bone}`} />
              <span className={`block h-3 w-1/2 ${bone}`} />
            </span>
          </>
        ) : (
          <div className="ex-fade-in flex items-center gap-4">
            <span aria-hidden className="grid size-11 shrink-0 place-items-center rounded-full bg-foreground text-sm font-semibold text-background">MK</span>
            <div>
              <p className="text-[15px] font-semibold leading-5">Mira Kovač</p>
              <p className="text-sm text-muted-foreground">Product designer</p>
            </div>
          </div>
        )}
      </div>
      <button type="button" onClick={() => { setDone(false); setRound((n) => n + 1); }}
        className="mx-auto mt-4 flex h-11 items-center gap-2 rounded-[10px] border border-border-strong px-4 text-sm font-medium hover:bg-surface">
        <RotateCw aria-hidden className="size-4" /> Load again
      </button>
    </div>
  );
}

See it in real apps

Still screenshots from the Inspireca Design library of the kinds of screen where this interaction is used. A screenshot cannot show the motion itself.

  • Interactive Examples

    Card that expands in place

    A summary card that opens to show its details without leaving the page, built on a real button and a height animation that needs no measuring.

  • Interactive Examples

    Button press, loading and success feedback

    A button that dips when pressed, shows a spinner while it works and confirms when it is done, with words that carry the meaning at every step.

  • Interactive Examples

    Tabs with a sliding indicator

    A marker that slides to the selected tab shows where you came from and where you are, with full arrow-key support.

  • Interactive Examples

    Dropdown menu with keyboard support

    A menu that opens from its button with a short fade and scale, and can be used completely from the keyboard.