Loading skeleton
Loading wrapper that shows shimmering pixel bars over its content and dissolves them as the content fades in when loading ends.
Playground
Change a prop and the component re-renders. Props marked remounts set an initial value, so the component starts over.
<PxSkeleton loading avatar lines={3}>Shared “Notes on the Analytical Engine” in Research. 3 comments, 12 reactions.</PxSkeleton>Installation
pnpm dlx shadcn@latest add @lumesec/px-skeletonFirst timeRegister the @lumesec registry once, or install by URL+
Adds @lumesec to your components.json:
pnpm dlx shadcn@latest registry add @lumesec=https://elements.lumesec.ai/r/{name}.jsonOr skip the setup and install by URL:
npx shadcn@latest add https://elements.lumesec.ai/r/px-skeleton.jsonUsage
import { PxSkeleton } from "@/components/lumesec/px-skeleton";
export function Example({ loading }: { loading: boolean }) {
return (
<PxSkeleton loading={loading} lines={3}>
<p>Shared “Notes on the Analytical Engine” in Research. 3 comments, 12 reactions.</p>
</PxSkeleton>
);
}Behaviour
Wraps real content and shows shimmering pixel bars in its shape while loading. Turning loading off dissolves the skeleton as the content fades in.
API reference
Props
Also accepts every prop of <div> (React.ComponentProps<"div">), spread onto the root element.
loadingTypebooleanDefaultfalseWhile true the content is transparent and the skeleton shimmers over it; turning it off dissolves the skeleton.
linesTypenumberDefault3Number of text bars.
avatarTypebooleanDefaultfalseAdds a 40 px circle on the left and shifts the bars to its right.
childrenTypeReact.ReactNodeThe real content. It keeps its size while loading, and the skeleton is drawn over that box.
Ref
ref points at the root HTMLDivElement.
Accessibility
- The root is an
aria-live="polite"region witharia-busyreflectingloading. - While loading, the content is transparent and
inert: it keeps its place in the layout but cannot be clicked, focused or read until loading ends. - The skeleton canvas is
aria-hidden. - Reduced motion: the shimmer wave stops; the dissolve and the content fade still run.
Theming
Styled with Tailwind classes on your shadcn theme tokens, so light and dark follow your theme. The accent comes from --lumesec. See Theming.
This component reads --foreground and --lumesec.
Notes
- The bars follow a fixed pattern of widths (100%, 90%, 62%, 80%, 50%) and are not traced from the content. Their spacing is computed from at most the first 120 px of height.
- The skeleton fills the content's box, so the content needs its real height while loading.
- The root carries
data-loadingwhile loading.
Related
Was this page helpful?