An open API service indexing awesome lists of open source software.

https://github.com/babarbilal56/react-skeleton-animation-loader

A lightweight and customizable React skeleton loader component with smooth animation effects. Ideal for improving user experience during content loading states.
https://github.com/babarbilal56/react-skeleton-animation-loader

loader loading nextjs react shimmer-effect shimmer-loading skeleton-loading

Last synced: 4 months ago
JSON representation

A lightweight and customizable React skeleton loader component with smooth animation effects. Ideal for improving user experience during content loading states.

Awesome Lists containing this project

README

          

example

# React Skeleton Animation Loader

A lightweight and customizable React skeleton loader component with smooth animation effects. Ideal for improving user experience during content loading states.

## Installation

Install the package using npm or yarn:

```sh
npm install react-skeleton-animation-loader
```

or

```sh
yarn add react-skeleton-animation-loader
```

## Usage

### Basic Example

```jsx
import React, { useState, useEffect } from 'react';
import SkeletonLoader from 'react-skeleton-animation-loader';

const ExampleComponent = () => {
const [loading, setLoading] = useState(true);

useEffect(() => {
setTimeout(() => setLoading(false), 3000);
}, []);

return (



Content loaded!




);
};

export default ExampleComponent;
```

## Props

| Prop | Type | Default | Description |
| ---------------- | -------------------- | -------- | -------------------------------------------------------------- |
| `type` | `string` | `'text'` | Specifies the skeleton type (`'text'`, `'image'`, `'custom'`). |
| `isLoading` | `boolean` | `true` | Controls the loading state. If `true`, the skeleton appears. |
| `children` | `ReactNode` | `null` | Content to be displayed when `isLoading` is `false`. |
| `skeletonWidth` | `string` or `number` | `'100%'` | Custom width for the skeleton loader. |
| `skeletonHeight` | `string` or `number` | `'100%'` | Custom height for the skeleton loader. |
| `count` | `number` | `1` | Number of skeleton elements (useful for `type='custom'`). |

## Examples

### Image Skeleton Loader

```jsx
import React, { useState, useEffect } from 'react';
import SkeletonLoader from 'react-skeleton-animation-loader';

const ImageExample = () => {
const [loading, setLoading] = useState(true);

useEffect(() => {
setTimeout(() => setLoading(false), 3000);
}, []);

return (



Loaded


);
};

export default ImageExample;
```

### Custom Skeleton List

```jsx
import React, { useState, useEffect } from 'react';
import SkeletonLoader from 'react-skeleton-animation-loader';

const ListExample = () => {
const [loading, setLoading] = useState(true);

useEffect(() => {
setTimeout(() => setLoading(false), 3000);
}, []);

return (



{[...Array(5)].map((_, index) => (

Item {index + 1}


))}


);
};

export default ListExample;
```

### Card Skeleton Loader

```jsx
import React, { useState, useEffect } from 'react';
import SkeletonLoader from 'react-skeleton-animation-loader';

const CardExample = () => {
const [loading, setLoading] = useState(true);

useEffect(() => {
setTimeout(() => setLoading(false), 3000);
}, []);

return (











{!loading && Click Me}

);
};

export default CardExample;
```

## Styling

You can customize the animation using CSS. Example:

```css
.skeleton-loader {
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
background-size: 200% 100%;
animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
```

## License

MIT