Directory
- Welcome
Skeleton Component
The Skeleton component creates smooth, animated loading states that enhance user experience while content loads. With four versatile variants and customizable lines, it adapts to various content layouts.
Key Features
-
Multiple Variants: Four pre-built layouts for common use cases
-
Customizable Lines: Adjustable number of lines for text content
-
Smooth Animations: Built-in loading animations
-
Responsive Design: Adapts to container width
Basic Usage
Image Skeleton
Perfect for image placeholders while content loads:
<Skeleton type="image" class="h-20" />
Text Skeleton
Simulate paragraph content with varying line widths:
<Skeleton type="text" class="h-20 max-w-lg" lines={6} />
Profile Layouts
Two variants for user cards and content previews:
Profile Type 1
<Skeleton type="profile" class="h-20" lines={2} />
Profile Type 2
<Skeleton type="profile-2" class="h-20 max-w-lg" lines={2} />
Props API
Prop | Type | Default | Description |
---|---|---|---|
type | `image` | `profile` | `text` | `profile-2` | `image` | Sets the skeleton layout style |
lines | number | Varies by type | Number of lines for text/profile variants |
Best Practices
-
Content Matching
- Match skeleton dimensions to actual content
- Use appropriate variant for content type
- Maintain consistent spacing
- Consider mobile layouts
-
Performance
- Use lazy loading when appropriate
- Optimize animation performance
- Consider reduced motion preferences
- Clean up on content load
Common Applications
Limited Time Launch Sale
Build better loading states today with our AstroJS starter template. Get instant access to the Skeleton component and many more UI elements.
GET 60% OFF!