Skip to main content

API Reference

<Skeleton />

The main component for skeleton loading.

Props

PropTypeDefaultDescription
loadingbooleanrequiredWhether to show the skeleton or render children
childrenReactNodeContent to measure for auto-skeleton generation
animation"pulse" | "shimmer" | "wave" | "solid""pulse"Animation style
durationnumber1.5Animation duration in seconds
density"low" | "medium" | "high""medium"DOM traversal depth for auto-detection
variant"auto" | "text" | "avatar" | "card" | "image" | "custom""auto" (with children)Skeleton variant or preset
ssrbooleanfalseEnable SSR-safe Boneyard Pattern
widthnumber | stringCustom width (for simple skeletons)
heightnumber | stringCustom height (for simple skeletons)
roundedbooleanForce rounded corners on all nodes
classNamestringCustom CSS class for wrapper
asReact.ElementType"div"Wrapper element type
styleReact.CSSPropertiesInline style for wrapper

Usage Modes

  1. Auto mode (default with children): Reads DOM layout and generates matching skeletons
  2. Preset mode: Use variant prop for built-in patterns
  3. Custom mode: Use width/height props for simple shapes
  4. Manual mode: Use sub-components for full control

<Skeleton.Text />

A text-line skeleton shape.

PropTypeDefaultDescription
widthnumber | string"100%"Line width
heightnumber | string16Line height
linesnumber1Number of text lines
gapnumber8Gap between lines (px)
animationAnimationVariant"pulse"Animation style
durationnumber1.5Animation duration
classNamestringCustom CSS class
styleReact.CSSPropertiesInline style

<Skeleton.Circle />

A circular skeleton shape (avatars, icons).

PropTypeDefaultDescription
sizenumber48Diameter in pixels
animationAnimationVariant"pulse"Animation style
durationnumber1.5Animation duration
classNamestringCustom CSS class
styleReact.CSSPropertiesInline style

<Skeleton.Block />

A rectangular skeleton shape.

PropTypeDefaultDescription
widthnumber | string"100%"Block width
heightnumber | string100Block height
roundedbooleantrueApply border-radius
animationAnimationVariant"pulse"Animation style
durationnumber1.5Animation duration
classNamestringCustom CSS class
styleReact.CSSPropertiesInline style

<Skeleton.Image />

An image placeholder skeleton with an icon.

PropTypeDefaultDescription
widthnumber | string"100%"Placeholder width
heightnumber | string200Placeholder height
animationAnimationVariant"pulse"Animation style
durationnumber1.5Animation duration
classNamestringCustom CSS class
styleReact.CSSPropertiesInline style

useSSRSkeleton(ssr: boolean)

Hook for SSR-safe skeleton rendering (used internally, but available for advanced use).

import { useSSRSkeleton } from "skelion";

const { isSSR, ssrClassName } = useSSRSkeleton(true);
ReturnTypeDescription
isSSRbooleantrue when rendering on server or before hydration
ssrClassNamestringCSS class to apply during SSR ("skeleton-ssr" or "")

CSS Variables

Override these in your CSS to customize the skeleton appearance:

:root {
--skeleton-color: #e5e7eb; /* Skeleton background color */
--skeleton-shimmer: rgba(255, 255, 255, 0.4); /* Shimmer/wave highlight */
--skeleton-radius: 4px; /* Default border radius */
--skeleton-duration: 1.5s; /* Animation duration */
}

Type Exports

import type {
SkeletonProps,
AnimationVariant,
Variant,
Density,
ShapePreset,
SkeletonNode,
SkeletonTextProps,
SkeletonCircleProps,
SkeletonBlockProps,
SkeletonImageProps,
} from "skelion";