Skeleton
Display a placeholder preview of your content before the data gets loaded to reduce load-time frustration.Overview
Skeleton screens (also called ghost elements or content placeholders) are used to indicate that content is loading. They provide a better user experience than traditional loading spinners by showing the shape of the content that will appear.Basic Usage
Variants
The component supports 4 shape variants:text(default) - Represents a single line of textcircular- Represents a circular element like an avatarrectangular- Represents a rectangular blockrounded- Represents a rectangular block with rounded corners
Animations
The skeleton supports three animation types:Inferring Dimensions
The Skeleton can infer its width and height from its children:Complex Example
Skeleton can be composed to create complex loading states:YouTube Example
A common pattern is to show a skeleton while loading media:Props
Main Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'text' | 'rectangular' | 'rounded' | 'circular' | 'text' | The type of content that will be rendered. |
animation | 'pulse' | 'wave' | false | 'pulse' | The animation. If false, the animation effect is disabled. |
width | number | string | - | Width of the skeleton. Useful when the skeleton is inside an inline element with no width of its own. |
height | number | string | - | Height of the skeleton. Useful when you don’t want to adapt the skeleton to a text element but for instance a card. |
sx | SxProps<Theme> | - | System prop for defining CSS overrides. |
children | ReactNode | - | Optional children to infer width and height from. |
Customization
Color
You can customize the color using thesx prop:
Custom Shapes
For custom shapes, you can override the border radius:Accessibility
Skeleton components should be used thoughtfully for accessibility:- They indicate loading state visually but may need additional ARIA attributes
- Consider adding
aria-busy="true"to the container - Ensure screen readers are informed when content loads
CSS Classes
The component has the following CSS classes available:.MuiSkeleton-root- Root element.MuiSkeleton-text- Text variant.MuiSkeleton-rectangular- Rectangular variant.MuiSkeleton-rounded- Rounded variant.MuiSkeleton-circular- Circular variant.MuiSkeleton-pulse- Pulse animation.MuiSkeleton-wave- Wave animation.MuiSkeleton-withChildren- Applied when children are provided.MuiSkeleton-fitContent- Applied when fitting to content
Best Practices
- Match the layout: Skeleton should closely match the final content’s layout
- Use appropriate variants: Choose the variant that best represents the content
- Combine with real layout: Use the same spacing and structure as the final content
- Progressive loading: Show skeletons for individual sections as they load
- Avoid over-use: Don’t skeleton every single element; focus on major content areas
API Reference
For complete API documentation, see:Source Location
~/workspace/source/packages/mui-material/src/Skeleton/Skeleton.d.ts:69