Skeleton
Use to show a placeholder while content is loading.
Installation
Install via CLI:
npx @sickui/cli add skeleton
Manual Installation
If you prefer to install manually, copy and paste the following code into your project.
npm install class-variance-authority clsx tailwind-merge
Usage
Variants
Use the variant prop to change the visual style of the Skeleton.
Default
Shimmer
Examples
Card Skeleton
Perfect for loading states of card components.
Loading State
A comprehensive loading state example showing profile, content, and action skeletons.
API Reference
Skeleton
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "shimmer" | "default" | The visual variant of the skeleton |
className | string | undefined | Additional CSS classes |
Accessibility
The Skeleton component includes:
- Semantic markup: Uses appropriate ARIA attributes for loading states
- Reduced motion: Respects user's motion preferences
- Screen reader support: Properly announced as loading content
Common Patterns
Text Skeleton
<div className="space-y-2">
<Skeleton className="h-4 w-full" />
<Skeleton className="h-4 w-4/5" />
<Skeleton className="h-4 w-3/5" />
</div>
Avatar Skeleton
<Skeleton className="h-10 w-10 rounded-full" />
Button Skeleton
<Skeleton className="h-10 w-20" />
Image Skeleton
<Skeleton className="h-48 w-full rounded-lg" />
Best Practices
- Match dimensions: Make skeleton dimensions similar to actual content
- Use appropriate shapes: Round skeletons for avatars, rectangular for text
- Maintain layout: Prevent layout shifts when content loads
- Consider animation: Use shimmer variant sparingly to avoid distraction
- Accessibility: Always provide loading indicators for screen readers