React Loading Components

2.0.3 · active · verified Wed Apr 22

react-loading provides a collection of easy-to-use, customizable loading animations for React applications. It leverages SVG animations adapted from Brent Jackson's `loading` project, offering a variety of types such as 'balls', 'bars', 'bubbles', and 'spin'. The current stable version is 2.0.3. The package has a somewhat sporadic release cadence, with updates addressing bug fixes and minor enhancements, rather than frequent new features. Its primary differentiators include the diverse range of aesthetically pleasing SVG-based animations and straightforward prop-based customization for color, size, and delay, making it a convenient choice for integrating visual loading states into React UIs without external stylesheets or complex setup.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates importing and rendering a `ReactLoading` component with dynamic type and color props, including styling for display.

import React from 'react';
import ReactLoading from 'react-loading';

const LoadingSpinner = ({ type, color, size = '64px' }) => {
  // Example usage for different loading types and dynamic sizing
  const loadingTypes = ['balls', 'spin', 'bubbles', 'cylon'];
  const chosenType = type || loadingTypes[Math.floor(Math.random() * loadingTypes.length)];

  return (
    <div style={{
      display: 'flex',
      justifyContent: 'center',
      alignItems: 'center',
      height: '100vh',
      backgroundColor: '#282c34'
    }}>
      <ReactLoading 
        type={chosenType} 
        color={color || '#fff'} 
        height={size} 
        width={size} 
        delay={0} 
      />
    </div>
  );
};

export default LoadingSpinner;

// To use this component:
// <LoadingSpinner type="spin" color="#61dafb" size="100px" />
// <LoadingSpinner type="balls" color="#a0a0a0" />

view raw JSON →