Skeleton

Muted placeholders while content loads. Skeleton breathes, for content reloading in place; Bone sweeps a light band across, for the workspace preview. Both hide from screen readers, so mark the region they fill aria-busy, and both hold still under reduced motion.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { Bone, Skeleton, SkeletonSwap } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Skeleton

Props

shape
className

SkeletonSwap

Props

loading

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoBuild the placeholder to the content's shape: line at the height of the text, circle for an avatar, box for a checkbox or small icon.
DoWrap it in SkeletonSwap, so the loaded content fades in where the skeleton was, the height eases and the region is marked busy.
DoMark the region aria-busy yourself when you use Skeleton or Bone without SkeletonSwap. Both are hidden from screen readers.
DoUse Skeleton for content reloading in place, and Bone for the workspace preview.
Don'tUse it for a short wait on one control, like saving a contact. Set the button's loading, or use Spinner.

Props

Skeleton

PropTypeDefaultDescription
shape"line" | "circle" | "box""line"Line (4 px radius) at the height of the text it stands in for, circle for avatars, box (2 px radius) for checkboxes and small icons.
classNamestring—Its size, like "h-3 w-40". The shape, colour and pulse are fixed.
styleCSSProperties—Inline styles on the root element, like a CSS variable it reads.

SkeletonSwap

PropTypeDefaultDescription
loading *boolean—Whether the content is still loading: shows the skeleton and marks the region busy.
skeleton *ReactNode—The placeholder, built from Skeleton or Bone to the content's shape.
children *ReactNode—The loaded content.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

Bone

PropTypeDefaultDescription
indexnumber0Its place in a block of bones, so the sweep moves down the block as one wave.
classNamestring—Its size and radius, like "h-3 w-40 rounded-md".
styleCSSProperties—Inline styles on the root element, like a CSS variable it reads.

Code

What the playground shows, ready to copy.

Skeleton

import { Skeleton } from "@leap-crm/design-system";

<Skeleton className="h-4 w-48" />

SkeletonSwap

import { Skeleton, SkeletonSwap } from "@leap-crm/design-system";

<SkeletonSwap loading skeleton={<Skeleton className="h-4 w-48" />}>
  <p>Jane Citizen</p>
</SkeletonSwap>

A loading row

Skeleton to content

SkeletonSwap trades the skeleton for the content in one place: the content fades and sharpens in as the skeleton fades out, and the height eases when they differ (here, two placeholder rows become three people), so nothing below jumps. The region is aria-busy while loading.

Jane CitizenReviewing the costs agreement
Sam TaylorWaiting on the title search
Priya NairSettlement booked for Friday

Bone

Each bone takes its index, so the sweep moves down the block as one wave.

What the examples share

The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.

import { useState } from "react";

import { Avatar, Bone, Button, Skeleton, SkeletonSwap } from "@leap-crm/design-system";

const wait = (ms: number) =>
  new Promise<void>(resolve => {
    setTimeout(resolve, ms);
  });

function LoadingRow() {
  return (
    <div className="flex items-center gap-3">
      <Skeleton shape="circle" className="size-8" />
      <div className="flex flex-1 flex-col gap-1.5">
        <Skeleton className="h-3.5 w-1/2" />
        <Skeleton className="h-3 w-3/4" />
      </div>
    </div>
  );
}

function Reload() {
  const [loading, setLoading] = useState(false);
  const load = async () => {
    setLoading(true);
    await wait(1200);
    setLoading(false);
  };
  return (
    <div className="flex w-80 flex-col items-start gap-4">
      <SkeletonSwap
        loading={loading}
        skeleton={
          <div className="flex flex-col gap-4">
            <LoadingRow />
            <LoadingRow />
          </div>
        }
        className="w-full"
      >
        <div className="flex flex-col gap-4">
          {[
            ["Jane Citizen", "JC", "Reviewing the costs agreement"],
            ["Sam Taylor", "ST", "Waiting on the title search"],
            ["Priya Nair", "PN", "Settlement booked for Friday"],
          ].map(([name = "", initials, note]) => (
            <div key={name} className="flex items-center gap-3">
              <Avatar
                name={name}
                initials={initials}
                size="lg"
                person="contact"
              />
              <div className="flex flex-col">
                <span className="text-body text-neutral-text">{name}</span>
                <span className="text-small text-neutral-text-muted">
                  {note}
                </span>
              </div>
            </div>
          ))}
        </div>
      </SkeletonSwap>
      <Button intent="outline" size="sm" onClick={load}>
        {loading ? "Loading…" : "Reload"}
      </Button>
    </div>
  );
}