react-loading-skeleton vs react-content-loader vs react-lazy-load-image-component vs react-loading vs react-placeholder
React Loading and Placeholder Libraries Comparison
1 Year
react-loading-skeletonreact-content-loaderreact-lazy-load-image-componentreact-loadingreact-placeholderSimilar Packages:
What's React Loading and Placeholder Libraries?

These libraries provide various methods to enhance user experience during loading states in React applications. They help to create visually appealing loading indicators and placeholders that can improve perceived performance by giving users feedback while content is being fetched or processed. Each library has its unique approach, offering different styles and functionalities for loading states, making it easier for developers to implement loading indicators that fit their application's design.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
react-loading-skeleton861,8904,12226.7 kB88 months agoMIT
react-content-loader512,88113,894162 kB19a year agoMIT
react-lazy-load-image-component198,4061,50495.4 kB575 months agoMIT
react-loading65,327814-207 years agoMIT
react-placeholder29,6511,613-234 years agoISC
Feature Comparison: react-loading-skeleton vs react-content-loader vs react-lazy-load-image-component vs react-loading vs react-placeholder

Customization

  • react-loading-skeleton:

    react-loading-skeleton is highly customizable, allowing developers to adjust the width, height, and shape of the skeleton components. This makes it easy to create loading states that closely resemble the final content layout, improving user experience.

  • react-content-loader:

    react-content-loader allows for extensive customization of the skeleton screens, enabling developers to define shapes and sizes that match the actual content layout. This flexibility helps create a seamless transition from loading to loaded states, enhancing user experience.

  • react-lazy-load-image-component:

    react-lazy-load-image-component offers customization options for lazy loading images, including the ability to define placeholder images or effects while the main image loads. This ensures that the user sees a relevant placeholder, improving the visual experience during loading.

  • react-loading:

    react-loading provides a variety of loading spinner styles and sizes, allowing developers to choose or customize the spinner that best fits their application's design. However, it has limited customization compared to other libraries focused on skeleton screens.

  • react-placeholder:

    react-placeholder supports customization of loading placeholders, including the ability to define the number of lines, width, and height of text placeholders. This flexibility allows developers to create visually appealing loading states that fit their application's design.

Performance Optimization

  • react-loading-skeleton:

    react-loading-skeleton is designed to be lightweight and efficient, ensuring that skeleton screens do not hinder the performance of the application. It helps maintain a smooth user experience during content loading.

  • react-content-loader:

    react-content-loader is optimized for performance, as it generates SVGs that are lightweight and efficient. This ensures that loading screens do not significantly impact the overall performance of the application, making it suitable for high-performance applications.

  • react-lazy-load-image-component:

    react-lazy-load-image-component significantly improves performance by loading images only when they are in the viewport. This reduces the initial load time and bandwidth usage, making it ideal for image-heavy applications.

  • react-loading:

    react-loading is lightweight and has minimal impact on performance, making it suitable for applications that require simple loading indicators without complex animations or heavy resources.

  • react-placeholder:

    react-placeholder is optimized for performance, allowing developers to create loading states without adding significant overhead to the application. It supports various loading types while maintaining efficient rendering.

Ease of Use

  • react-loading-skeleton:

    react-loading-skeleton is easy to implement, providing a simple API that allows developers to create skeleton screens with minimal configuration. This makes it a great choice for projects that need quick loading indicators.

  • react-content-loader:

    react-content-loader is easy to use, requiring minimal setup to create skeleton screens. Its straightforward API allows developers to quickly implement loading states without extensive configuration.

  • react-lazy-load-image-component:

    react-lazy-load-image-component is user-friendly, providing a simple API for lazy loading images. Developers can easily integrate it into their applications with minimal effort, making it accessible for beginners.

  • react-loading:

    react-loading is designed for simplicity, allowing developers to quickly add loading spinners to their applications with just a few lines of code. Its ease of use makes it a popular choice for quick implementations.

  • react-placeholder:

    react-placeholder is straightforward to use, offering a simple API for creating various loading placeholders. Developers can quickly implement loading states without complex setup, making it beginner-friendly.

Visual Appeal

  • react-loading-skeleton:

    react-loading-skeleton provides visually appealing skeleton screens that enhance the user experience by mimicking the structure of the content. This helps users understand what to expect while the content loads.

  • react-content-loader:

    react-content-loader excels in creating visually appealing skeleton screens that closely mimic the layout of the actual content. This enhances the user experience by providing a smooth transition from loading to loaded states.

  • react-lazy-load-image-component:

    react-lazy-load-image-component allows for the use of placeholder images, which can be visually appealing and relevant to the content being loaded. This helps maintain user engagement during image loading.

  • react-loading:

    react-loading offers a variety of spinner designs that can be visually appealing, but it may not match the content layout as effectively as skeleton screens. It is best used for simple loading indicators rather than complex content.

  • react-placeholder:

    react-placeholder supports various loading types, allowing developers to create visually appealing placeholders that fit different content types. This versatility helps maintain user engagement during loading.

Community and Support

  • react-loading-skeleton:

    react-loading-skeleton has a growing community and good documentation, offering developers the resources needed to implement and customize skeleton screens effectively.

  • react-content-loader:

    react-content-loader has a strong community and good documentation, making it easy for developers to find support and examples. This helps in quickly resolving issues and implementing features effectively.

  • react-lazy-load-image-component:

    react-lazy-load-image-component benefits from an active community and comprehensive documentation, providing developers with resources and support for implementation and troubleshooting.

  • react-loading:

    react-loading has a decent community and sufficient documentation, but it may not be as extensive as other libraries. Developers can still find support and examples to assist with implementation.

  • react-placeholder:

    react-placeholder has a supportive community and adequate documentation, making it easy for developers to find help and examples for creating loading placeholders.

How to Choose: react-loading-skeleton vs react-content-loader vs react-lazy-load-image-component vs react-loading vs react-placeholder
  • react-loading-skeleton:

    Opt for react-loading-skeleton when you want to create skeleton screens that are easy to implement and highly customizable. This library is particularly useful for providing a smooth user experience by displaying placeholders that resemble the structure of your content while it loads.

  • react-content-loader:

    Choose react-content-loader if you need customizable SVG-based skeleton screens that mimic the layout of your content. It is ideal for creating visually appealing loading states that match your application's design, especially when you want to provide a smooth transition from loading to loaded content.

  • react-lazy-load-image-component:

    Select react-lazy-load-image-component when you want to optimize image loading by lazy loading images as they enter the viewport. This package is perfect for applications with many images, as it helps improve performance and reduce initial load times by loading images only when necessary.

  • react-loading:

    Use react-loading if you need a simple and customizable loading spinner or indicator. This package is great for applications that require a straightforward loading animation without the need for complex configurations or styles, making it easy to implement and use.

  • react-placeholder:

    Choose react-placeholder if you need a versatile library that supports various loading types, including text and image placeholders. It is suitable for applications that require a quick and flexible solution for loading states, allowing you to easily create placeholders that fit different content types.

README for react-loading-skeleton
Logo

React Loading Skeleton

Make beautiful, animated loading skeletons that automatically adapt to your app.

Open on CodeSandbox

Gif of the skeleton in action

Learn about the changes in version 3, or view the v2 documentation.

Basic Usage

Install via one of:

yarn add react-loading-skeleton
npm install react-loading-skeleton
import Skeleton from 'react-loading-skeleton'
import 'react-loading-skeleton/dist/skeleton.css'

<Skeleton /> // Simple, single-line loading skeleton
<Skeleton count={5} /> // Five-line loading skeleton

Principles

Adapts to the styles you have defined

The Skeleton component should be used directly in your components in place of content that is loading. While other libraries require you to meticulously craft a skeleton screen that matches the font size, line height, and margins of your content, the Skeleton component is automatically sized to the correct dimensions.

For example:

function BlogPost(props) {
  return (
    <div>
      <h1>{props.title || <Skeleton />}</h1>
      {props.body || <Skeleton count={10} />}
    </div>
  );
}

...will produce correctly-sized skeletons for the heading and body without any further configuration.

This ensures the loading state remains up-to-date with any changes to your layout or typography.

Don't make dedicated skeleton screens

Instead, make components with built-in skeleton states.

This approach is beneficial because:

  1. It keeps styles in sync.
  2. Components should represent all possible states — loading included.
  3. It allows for more flexible loading patterns. In the blog post example above, it's possible to have the title load before the body, while having both pieces of content show loading skeletons at the right time.

Theming

Customize individual skeletons with props, or render a SkeletonTheme to style all skeletons below it in the React hierarchy:

import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';

return (
  <SkeletonTheme baseColor="#202020" highlightColor="#444">
    <p>
      <Skeleton count={3} />
    </p>
  </SkeletonTheme>
);

Props Reference

Skeleton only

PropDescriptionDefault
count?: number The number of lines of skeletons to render. If count is a decimal number like 3.5, three full skeletons and one half-width skeleton will be rendered. 1
wrapper?: React.FunctionComponent
<PropsWithChildren<unknown>>
A custom wrapper component that goes around the individual skeleton elements.
circle?: boolean Makes the skeleton circular by setting border-radius to 50%. false
className?: string A custom class name for the individual skeleton elements which is used alongside the default class, react-loading-skeleton.
containerClassName?: string A custom class name for the <span> that wraps the individual skeleton elements.
containerTestId?: string A string that is added to the container element as a data-testid attribute. Use it with screen.getByTestId('...') from React Testing Library.
style?: React.CSSProperties This is an escape hatch for advanced use cases and is not the preferred way to style the skeleton. Props (e.g. width, borderRadius) take priority over this style object.

Skeleton and SkeletonTheme

PropDescriptionDefault
baseColor?: stringThe background color of the skeleton.#ebebeb
highlightColor?: stringThe highlight color in the skeleton animation.#f5f5f5
width?: string | numberThe width of the skeleton.100%
height?: string | numberThe height of each skeleton line.The font size
borderRadius?: string | numberThe border radius of the skeleton.0.25rem
inline?: boolean By default, a <br /> is inserted after each skeleton so that each skeleton gets its own line. When inline is true, no line breaks are inserted. false
duration?: numberThe length of the animation in seconds.1.5
direction?: 'ltr' | 'rtl' The direction of the animation, either left-to-right or right-to-left. 'ltr'
enableAnimation?: boolean Whether the animation should play. The skeleton will be a solid color when this is false. You could use this prop to stop the animation if an error occurs. true
customHighlightBackground?: string Allows you to override the background-image property of the highlight element, enabling you to fully customize the gradient. See example below. undefined

Examples

Custom Wrapper

There are two ways to wrap a skeleton in a container:

function Box({ children }: PropsWithChildren<unknown>) {
  return (
    <div
      style={{
        border: '1px solid #ccc',
        display: 'block',
        lineHeight: 2,
        padding: '1rem',
        marginBottom: '0.5rem',
        width: 100,
      }}
    >
      {children}
    </div>
  );
}

// Method 1: Use the wrapper prop
const wrapped1 = <Skeleton wrapper={Box} count={5} />;

// Method 2: Do it "the normal way"
const wrapped2 = (
  <Box>
    <Skeleton />
  </Box>
);

Custom Highlight Background

You may want to make the gradient used in the highlight element narrower or wider. To do this, you can set the customHighlightBackground prop. Here's an example of a narrow highlight:

<Skeleton customHighlightBackground="linear-gradient(90deg, var(--base-color) 40%, var(--highlight-color) 50%, var(--base-color) 60%)" />

If you use this prop, the baseColor and highlightColor props are ignored, but you can still reference their corresponding CSS variables as shown in the above example.

Custom highlight background example

Troubleshooting

The skeleton width is 0 when the parent has display: flex!

In the example below, the width of the skeleton will be 0:

<div style={{ display: 'flex' }}>
  <Skeleton />
</div>

This happens because the skeleton has no intrinsic width. You can fix it by applying flex: 1 to the skeleton container via the containerClassName prop.

For example, if you are using Tailwind, your code would look like this:

<div style={{ display: 'flex' }}>
  <Skeleton containerClassName="flex-1" />
</div>

The height of my container is off by a few pixels!

In the example below, the height of the <div> will be slightly larger than 30 even though the react-loading-skeleton element is exactly 30px.

<div>
  <Skeleton height={30} />
</div>

This is a consequence of how line-height works in CSS. If you need the <div> to be exactly 30px tall, set its line-height to 1. See here for more details.

Contributing

Contributions are welcome! See CONTRIBUTING.md to get started.

Acknowledgements

Our logo is based off an image from Font Awesome. Thanks!