Skip to content

Skeleton

A flexible loading placeholder component for enhancing user experience during data loading. Supports text, circular, and rectangular variants, multiple lines, animation, custom sizing, and convenient helpers for avatars, cards, buttons, inputs, images, and tables.


Import

tsx
import { Skeleton } from '@odyssee/components';
// Helpers: Skeleton.Avatar, Skeleton.Card, Skeleton.Text, Skeleton.Circle, Skeleton.Rectangle, Skeleton.Button, Skeleton.Input, Skeleton.Image, Skeleton.Table

Examples

Basic Skeleton

Code Éditable
Résultat

Variants

Code Éditable
Résultat

Gap Sizes

Code Éditable
Résultat

Avatar Skeleton

Code Éditable
Résultat

Card Skeleton

Code Éditable
Résultat

Button, Input, Image, and Table Skeletons

Code Éditable
Résultat

Props Table

Skeleton

PropTypeDefaultDescription
variant"text" | "circular" | "rectangular""text"Shape of the skeleton.
widthstring | numberWidth of the skeleton (px or %).
heightstring | numberHeight of the skeleton (px or %).
animatebooleanfalseEnable pulse animation.
linesnumber1Number of lines (for text variant).
gap"sm" | "md" | "lg""md"Vertical gap between lines.
classNamestringAdditional CSS classes.
idstringauto-genHTML id attribute.
stylestringInline styles.

Skeleton.Avatar

PropTypeDefaultDescription
size"xs" | "sm" | "md" | "lg" | "xl""md"Size of the avatar skeleton.
animatebooleanfalseEnable pulse animation.
classNamestringAdditional CSS classes.
idstringauto-genHTML id attribute.

Skeleton.Card

PropTypeDefaultDescription
avatarbooleantrueShow avatar skeleton.
avatarSize"xs" | "sm" | "md" | "lg" | "xl""md"Size of the avatar.
linesnumber4Number of text lines.
animatebooleanfalseEnable pulse animation.
titleWidthstring"40%"Width of the title skeleton.
classNamestringAdditional CSS classes.
idstringauto-genHTML id attribute.

Helper Components

  • Skeleton.Text: Text skeleton (multiple lines)
  • Skeleton.Circle: Circular skeleton
  • Skeleton.Rectangle: Rectangular skeleton
  • Skeleton.Button: Button skeleton (width, height)
  • Skeleton.Input: Input skeleton (width, height)
  • Skeleton.Image: Image skeleton (width, height)
  • Skeleton.Table: Table skeleton (rows, animate)

Implementation Notes

  • Variants:
    • "text": Rounded lines, ideal for paragraphs or titles.
    • "circular": Perfect for avatars or icons.
    • "rectangular": For images, cards, or blocks.
  • Helpers: Use provided helpers for common skeleton patterns (avatar, card, button, input, image, table).
  • Animation: Use animate for a pulsing loading effect.
  • Sizing: Use width/height for precise control, or helper size props for avatars.
  • Composition: Combine skeletons for complex layouts (e.g., card with avatar and lines).

Accessibility

  • Skeletons are rendered as <span>, <ul>, or <div> and are visually hidden from assistive tech by default.
  • Do not use skeletons as a replacement for semantic content.
  • When loading is complete, replace skeletons with real content and ensure focus/ARIA updates as needed.
  • For important loading states, consider using aria-busy or live regions on the parent container.

Best Practices

  • Use skeletons to indicate loading for lists, cards, avatars, forms, and images.
  • Prefer animated skeletons for longer loading times.
  • Match the skeleton layout to the eventual content for a smooth transition.
  • Avoid using only spinners for large content areas—skeletons provide better perceived performance.
  • Combine with conditional rendering and loading state management for best UX.


Released under the MIT License.