Skeleton
A skeleton loading component that displays placeholder content while data is loading
Installation
Terminal
Import
Component.tsx
Basic
Basic: Demonstrates the fundamental usage of Skeleton component.
- Toggle the loading state to see the transition effect.
- When loading is true, the wrapped content displays as a skeleton.
- When loading is false, the actual content is revealed with a smooth transition.
Standalone
Standalone: Demonstrates Skeleton as an independent placeholder element.
- Use without children to create standalone skeleton placeholders.
- Specify dimensions using `width` and `height` props.
- Accepts both number (pixels) and string (any CSS unit) values.
- Useful for creating custom loading layouts before content structure is known.
Skeleton without children - dimensions specified via props:
Text line (width: 200, height: 16):
Paragraph block (width: 100%, height: 80):
Avatar placeholder (width: 48, height: 48):
Button placeholder (width: 120, height: 36):
Standalone Layout
StandaloneLayout: Shows how to build a complete loading layout using standalone Skeletons.
- Creates a card-like loading state without actual content components.
- Useful when the actual content structure hasn't been loaded yet.
- Demonstrates combining multiple standalone Skeletons for complex layouts.
Loading Prop
LoadingProp: Shows how to control individual Skeleton components with the `loading` prop.
- Each Skeleton can be controlled independently.
- When `loading` is true, children are hidden and replaced with a skeleton effect.
- Useful for granular control over different parts of the UI.
Button:
Input:
Avatar:
J
Card:
Card Title
Card content goes here
SkeletonProvider
SkeletonProviderUsage: Demonstrates unified loading control with SkeletonProvider.
- Wrap multiple Skeleton components with SkeletonProvider.
- All nested Skeletons inherit the loading state from the provider.
- Individual Skeleton `loading` props take precedence over provider.
- Ideal for page-level or section-level loading states.
All components below are controlled by SkeletonProvider:
Card Title
Card content goes here
J
User NameUser description
Profile Card
ProfileCard: Real-world example of a user profile card with skeleton loading.
- Shows a complete profile layout with avatar, name, title, and action buttons.
- Demonstrates how Skeleton preserves the layout structure during loading.
- Each element maintains its size and position for a smooth loading experience.
J
John DoeSoftware EngineerSan Francisco, CA
Form Layout
FormLayout: Demonstrates skeleton loading for form elements.
- Shows a typical form with text inputs and a textarea.
- Skeleton maintains form field dimensions during loading.
- Action buttons are also wrapped for a complete loading experience.
List Items
ListItems: Shows skeleton loading for list-based layouts.
- Each List.Item is wrapped with Skeleton individually.
- Maintains consistent item heights and spacing during loading.
- Ideal for data-driven lists, feeds, or navigation menus.
Transition Effect
TransitionEffect: Demonstrates the smooth transition animation.
- Shows how Skeleton transitions smoothly between loading and loaded states.
- Both entering (content → skeleton) and leaving (skeleton → content) have transitions.
- The transition is powered by CSS transitions on background, border, and opacity.
Current: Loading
Click the button and observe the smooth transition in both directions:
T
Card Content
Mixed Content
MixedContent: Shows a complex layout combining multiple component types.
- Demonstrates how SkeletonProvider can control a diverse set of elements.
- Includes headings, paragraphs, buttons, and cards.
- Represents a typical page section with mixed content types.
Page Title
This is a page description that explains the content below.
Card Section
Card content with detailed information.
API reference
| SkeletonProps | Type | Default |
|---|---|---|
className | string |undefined | - |
children | ReactNode | - |
asChild | boolean |undefined | - |
height | string |number |undefined | - |
loading | boolean |undefined | undefined (falls back to Context) |
variant | undefined |"text" |"rectangular" |"rounded" |"circular" | 'text' |
width | string |number |undefined | - |
ref | ((instance: HTMLSpanElement |null) => void) |RefObject<HTMLSpanElement> |null |undefined | - |
| SkeletonProvider | Type | Default |
loading | boolean | - |