Skeleton
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.
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
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
text (lines), circle (avatar) or rect (media, cards). Defaults to "text".
CSS width; a number means pixels. Defaults to the full width, and to 40px for a circle.
CSS height; a number means pixels. A circle uses its width when omitted.
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
| Hook | Values |
|---|---|
.cherry-skeleton | Root element |
data-shape | text, circle, rect |
.cherry-skeleton__line | One 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.