Skeleton

Placeholder shapes that match the layout they stand in for, with one sweep of light that respects reduced motion.

Loading members

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/skeleton

Usage

import { Skeleton, SkeletonGroup } from "./ui/uicontext/components/Skeleton.ts"
export const CommentLoading = <M>(h: Html.H<M>) =>	SkeletonGroup(h, { label: "Loading comments" }).children(		Skeleton(h, { shape: "circle" }),		Skeleton(h, { text: "base", lines: 3 }),	)

Examples

Shapes

A block keeps the cover's aspect ratio, each text line takes its font size, and a circle stands in for a face.

Loading documents

API reference

SkeletonView function

Options

Skeleton options
NameTypeDefaultDescription
shape"text" | "circle" | "rect"—text for a line of text (pass text for its size), circle for an avatar or an icon, rect for an image, a chart or a field. text when text or lines is given, rect otherwise.
text"xs" | "sm" | "base" | "lg" | "xl" | "xxl"baseThe font size of the text it stands in for, so the line is as tall as the text will be; base by default.
linesnumber1Lines of a paragraph, the last one shorter; 1 by default.
styleStyle—StyleX styles for the size the real content takes: { inlineSize: 120 } for a short title, { inlineSize: 40, blockSize: 40 } for a larger avatar, an aspect ratio for an image.

SkeletonGroupView function

Options

SkeletonGroup options
NameTypeDefaultDescription
labelrequiredstring—What's loading, read once to a screen reader: "Loading issues".
delaybooleantrueWait 300 ms before showing, so a load that finishes quickly shows nothing at all; true by default. Turn it off when the placeholder is the first paint of a page.
styleStyle—StyleX styles for the group's box; it adds none of its own, so the shapes sit in your layout.

Source