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)