Skip to content

Feedback

Skeleton

tsx
import { Skeleton } from "@cherry-design-system/react";

export function LoadingText() {
  return (
    <div aria-busy="true">
      <Skeleton shape="text" lines={3} />
    </div>
  );
}

Skeleton is a loading placeholder with a shimmer. It keeps the layout in place while content loads, so the page does not jump when the data arrives. For a short wait without a known layout, use Spinner.

Examples

Shapes

text draws lines (the last one is shorter), circle fits an avatar and rect fits media or cards.

tsx
import { Skeleton } from "@cherry-design-system/react";

export function Shapes() {
  return (
    <>
      <Skeleton shape="text" lines={2} />
      <Skeleton shape="circle" width={48} />
      <Skeleton shape="rect" width="50%" height="8rem" />
    </>
  );
}

A loading card

tsx
import { Skeleton } from "@cherry-design-system/react";

export function ProfileCardSkeleton() {
  return (
    <div aria-busy="true" aria-label="Loading profile" style={{ display: "flex", gap: 12 }}>
      <Skeleton shape="circle" width={40} />
      <div style={{ flex: 1 }}>
        <Skeleton shape="text" lines={2} />
      </div>
    </div>
  );
}

Properties

shape"text" | "circle" | "rect"

text (lines), circle (avatar) or rect (media, cards). Defaults to "text".

widthnumber | string

CSS width; a number means pixels. Defaults to the full width, and to 40px for a circle.

heightnumber | string

CSS height; a number means pixels. A circle uses its width when omitted.

linesnumber

Number of text lines; the last one is shorter. Defaults to 1.

Skeleton renders a <span aria-hidden="true">, forwards its ref to it and passes every other <span> attribute through. It has no client JavaScript, so it is safe in Server Components.

Styling

HookValues
.cherry-skeletonRoot element
data-shapetext, circle, rect
.cherry-skeleton__lineOne text line

The base reads --cherry-bg-muted and the shimmer --cherry-bg-canvas. The shimmer stops under prefers-reduced-motion.

Accessibility

A Skeleton is hidden from screen readers. Mark the region that is loading with aria-busy="true" instead, and remove it once the content is in.