React Loading Components
A lightweight and customizable React component library for loading indicators and skeleton screens. Built with TypeScript for full type safety and excellent developer experience.
✨ Features
- 🚀 Lightweight - Minimal bundle size impact
- 🎨 Customizable - Full control over appearance and behavior
- 📝 TypeScript - Complete type definitions included
- ♿ Accessible - ARIA labels and screen reader support
- 🌳 Tree-shakeable - Import only what you need
- ⚡ Performance - Optimized animations using CSS
📦 Installation
npm install react-loading-components
yarn add react-loading-components
pnpm add react-loading-components
🚀 Quick Start
import {
LoadingSpinner,
PulseLoader,
Skeleton,
} from "react-loading-components";
function App() {
return (
<div>
{/* Basic spinner */}
<LoadingSpinner />
{/* Customized spinner */}
<LoadingSpinner
size={50}
color="#ff6b6b"
showText={true}
text="Loading data..."
/>
{/* Pulse loader */}
<PulseLoader count={5} color="#10b981" />
{/* Skeleton placeholder */}
<Skeleton width="100%" height={24} />
</div>
);
}
📖 Components
LoadingSpinner
A classic spinning loading indicator.
<LoadingSpinner
size={40}
color="#3b82f6"
speed={1}
thickness={4}
showText={false}
text="Loading..."
ariaLabel="Loading..."
className=""
/>
PulseLoader
An animated pulse loading indicator with multiple dots.
<PulseLoader
size={12}
color="#3b82f6"
speed={1.4}
count={3}
ariaLabel="Loading..."
className=""
/>
Skeleton
A skeleton placeholder for content loading states.
<Skeleton
width="100%"
height={20}
borderRadius={4}
animate={true}
speed={2}
className=""
/>
🚀 Publishing to NPM
This library is set up for easy publishing to NPM:
- Build the library:
npm run build:lib
- Update version:
npm version patch
(or minor
/major
)
- Publish:
npm publish
The prepublishOnly
script ensures the library is built before publishing.
🛠️ Development
npm run dev
npm run build:lib
Expanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
export default tseslint.config({
extends: [
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
],
languageOptions: {
parserOptions: {
project: ["./tsconfig.node.json", "./tsconfig.app.json"],
tsconfigRootDir: import.meta.dirname,
},
},
});
You can also install eslint-plugin-react-x and eslint-plugin-react-dom for React-specific lint rules:
import reactX from "eslint-plugin-react-x";
import reactDom from "eslint-plugin-react-dom";
export default tseslint.config({
plugins: {
"react-x": reactX,
"react-dom": reactDom,
},
rules: {
...reactX.configs["recommended-typescript"].rules,
...reactDom.configs.recommended.rules,
},
});