Skeleton loaders are one of the most effective ways to improve perceived performance in a React app. Instead of showing a blank screen or a generic spinner, you simulate the layout of your content while it's loading.
With skeleton-loader-ap
, adding responsive, customizable loading placeholders is super simple.
π¦
skeleton-loader-ap
β Why Use Skeleton Loaders?
- π§© They hint at content layout before it's loaded
- π Improve perceived speed and UX
- π§ More context than loading spinners
- π± Great for images, avatars, text, cards, and more
π¦ Installation
Install with npm:
bash
npm install skeleton-loader-ap
Or with Yarn:
bash
Copy
Edit
yarn add skeleton-loader-ap
π§ Components Overview
1. <Skeleton /> β Base Skeleton Block
<Skeleton width="100%" height="1rem" borderRadius="6px" />
Props:
width (string | number)
height (string | number)
circle (boolean)
borderRadius (string | number)
placeholder (boolean | string) β true or custom image path
opacity (number | string)
2. <SkeletonImage /> β Image Loader
<SkeletonImage size={80} circle placeholder />
Extra Props:
size β square size for both width/height
circle β inferred if size is passed
3. <SkeletonParagraph /> β Multi-line Loader
<SkeletonParagraph
rows={3}
widths={['90%', '100%', '80%']}
spacing="0.75rem"
placeholder
/>
Props:
rows β number of lines (default 3)
widths β array of individual line widths
lineHeight β default '1rem'
spacing β default '0.5rem'
placeholder, opacity, borderRadius
4. <SkeletonClientWrapper /> β Auto Loader Wrapper
<SkeletonClientWrapper
type="Image"
size={100}
circle
placeholder
loadertime={3000}
/>
<SkeletonClientWrapper
type="Paragraph"
rows={4}
widths={['90%', '100%', '80%', '70%']}
placeholder
/>
Props:
type: 'Image' or 'Paragraph'
loadertime: how long (in ms) to show skeleton
All props passed to respective component
πͺ useSkeleton Hook
Manually control loading:
const loading = useSkeleton(3000); // `true` for 3 seconds
Use this to conditionally show skeletons or actual content.
πΌ Placeholder Images
Built-in default image:
<Skeleton placeholder />
Custom image from /public/Images/your-loader.gif:
<Skeleton placeholder="/Images/custom-spinner.gif" />
π§ͺ Full Example
import {
SkeletonClientWrapper,
SkeletonImage,
SkeletonParagraph,
} from 'skeleton-loader-ap';
function ProfileLoader() {
return (
<div className="flex gap-4">
<SkeletonClientWrapper
type="Image"
size={80}
circle
placeholder
loadertime={3000}
/>
<SkeletonClientWrapper
type="Paragraph"
rows={3}
widths={['80%', '90%', '70%']}
placeholder
spacing="1rem"
/>
</div>
);
}
π Features Recap
π Highly customizable
π§© Modular components (Image, Text, Block)
β³ Client-side wrapper for simulated loading
πͺ Hook for manual control
πΌ Built-in + custom image placeholders
π¦ Lightweight with no external dependencies
π Links(https://github.com/ankitparashar700/npm-skeleton-loader-ap/)
π View on NPM
π§ GitHub Repository
If this helped you, give the package a β on GitHub and share it with your dev team!
Happy loading! π¦΄
Top comments (0)