SkeletonnewNEW
A placeholder loading state that mimics the layout of content while it's being loaded.
Usage
The Skeleton component is used to create placeholder loading states that represent the layout of content while it's being loaded. It provides a visual indication that content is loading and helps maintain layout stability.
Skeleton Props
Prop | Type | Default |
---|---|---|
width | string | number | "50px for inline, 100% otherwise" |
height | string | number | "var(--rs-space-4)" |
baseColor | string | "var(--rs-color-background-base-primary-hover)" |
highlightColor | string | "var(--rs-color-background-base-primary)" |
borderRadius | string | number | "var(--rs-radius-2)" |
inline | boolean | false |
duration | number | 1.5 |
enableAnimation | boolean | true |
count | number | 1 |
className | string | - |
style | CSSProperties | - |
containerClassName | string | - |
containerStyle | CSSProperties | - |
Examples
Basic Usage
A simple skeleton loader with fixed dimensions.
Multiple Lines
Create multiple skeleton lines using the count prop.
Using Provider
Group multiple skeletons and share common props using Skeleton.Provider.
Custom Styles
Customize the appearance using baseColor and highlightColor.
Animation Control
Control the animation duration or disable it entirely.
Complex Layout
Create a card-like loading state by combining multiple skeletons.
Provider Pattern
The Skeleton component supports a Provider pattern that allows you to share common props across multiple skeleton instances:
All props available on the Skeleton component can be passed to the Provider and will be inherited by child Skeleton components. Individual Skeleton components can override any provider props with their own values.
Accessibility
The Skeleton component follows accessibility best practices:
- Uses semantic HTML elements
- Provides appropriate ARIA attributes
- Maintains sufficient color contrast
- Animation can be disabled for users who prefer reduced motion
- Supports both block and inline layouts