Socket
Socket
Sign inDemoInstall

react-spinners

Package Overview
Dependencies
5
Maintainers
1
Versions
148
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-spinners

A collection of react loading spinners


Version published
Weekly downloads
335K
increased by1.94%
Maintainers
1
Install size
495 kB
Created
Weekly downloads
 

Changelog

Source

0.13.8

  • bugfix: Remove Animation Fill Mode from CircieLoader to fix SSR mismatch style error. #558

Readme

Source

React Spinners

npm version downloads license

Coverage Status Dependency Count Types Included Tree Shaking Supported

A collection of loading spinners with React.js based on Halogen.

This package is bootstraped using react-npm-boilerplate

Demo

Demo Page

Storybook

Installation

With Yarn:

yarn add react-spinners

With npm:

npm install --save react-spinners

Usage

Each loader has their own default properties. You can overwrite the defaults by passing props into the loaders.

Each loader accepts a loading prop as a boolean. The loader will render null if loading is false.

Example

import { useState, CSSProperties } from "react";
import ClipLoader from "react-spinners/ClipLoader";

const override: CSSProperties = {
  display: "block",
  margin: "0 auto",
  borderColor: "red",
};

function App() {
  let [loading, setLoading] = useState(true);
  let [color, setColor] = useState("#ffffff");

  return (
    <div className="sweet-loading">
      <button onClick={() => setLoading(!loading)}>Toggle Loader</button>
      <input value={color} onChange={(input) => setColor(input.target.value)} placeholder="Color of the loader" />

      <ClipLoader
        color={color}
        loading={loading}
        cssOverride={override}
        size={150}
        aria-label="Loading Spinner"
        data-testid="loader"
      />
    </div>
  );
}

export default App;
Example using React Class
import React from "react";
import ClipLoader from "react-spinners/ClipLoader";

const override: React.CSSProperties = {
  display: "block",
  margin: "0 auto",
  borderColor: "red",
};

class AwesomeComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      loading: true,
    };
  }

  render() {
    return (
      <div className="sweet-loading">
        <ClipLoader
          cssOverride={override}
          size={150}
          color={"#123abc"}
          loading={this.state.loading}
          speedMultiplier={1.5}
          aria-label="Loading Spinner"
          data-testid="loader"
        />
      </div>
    );
  }
}

Available Loaders, PropTypes, and Default Values

Common default props for all loaders:

loading: true;
color: "#000000";
cssOverride: {}
speedMultiplier: 1;

All valid HTML props such as aria-* and data-* props are fully supported.

color prop

color prop accepts a color hash in the format of #XXXXXX or #XXX. It also accepts basic colors listed below:

maroon, red, orange, yellow, olive, green, purple, white, fuchsia, lime, teal, aqua, blue, navy, black, gray, silver

cssOverride prop

The cssOverride prop is an object of camelCase styles used to create inline styles on the loaders. Any html css property is valid here.

size, height, width, and radius props

The input to these props can be number or string.

  • If value is number, the loader will default to css unit px.
  • If value is string, the loader will verify the unit against valid css units.
    • If unit is valid, return the original value
    • If unit is invalid, output warning console log and default to px.

The table below has the default values for each loader.

Loadersizeheightwidthradiusmargin
BarLoader4100
BeatLoader152
BounceLoader60
CircleLoader50
ClimbingBoxLoader15
ClipLoader35
ClockLoader50
DotLoader602
FadeLoader15522
GridLoader15
HashLoader502
MoonLoader602
PacmanLoader252
PropagateLoader15
PuffLoader60
PulseLoader152
RingLoader602
RiseLoader152
RotateLoader152
ScaleLoader35422
SyncLoader152

Keywords

FAQs

Last updated on 19 Jan 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc