A collection of react loading spinners
React Spinners is a highly popular npm package designed to enhance web applications with visually appealing loading indicators. This node module offers a diverse collection of spinner components that are seamlessly compatible with React projects. Leveraging CSS animations, React Spinners provides a smooth and eye-catching user experience while content is loading, making it an essential tool for developers looking to maintain user engagement during wait times. The package includes a variety of spinner styles, each customizable with easy-to-use props, allowing developers to match the loading indicators with the application's overall design seamlessly.
To incorporate React Spinners into your project, simply run the command "npm install react-spinners". This installation process integrates the package into your React application, enabling you to utilize any of the spinner designs immediately. Each spinner component is optimized for performance and accessibility, ensuring that they do not detract from the user experience but rather enhance it. The availability of multiple spinner options allows developers to select one that best fits the aesthetic and functional requirements of their applications. With React Spinners, developers can easily implement an effective visual cue that informs users that data processing or fetching is currently underway, thereby improving the overall user interface.
React Spinners not only supports a broad range of modern and traditional designs but also promotes consistency across different browsers and devices. This compatibility is crucial for developers aiming to provide a uniform user experience, irrespective of the user's technology. The spinners are also designed to be lightweight, ensuring that they do not impact the load time or performance of the application adversely. By using React Spinners, developers can achieve an optimal balance between functionality and aesthetic appeal, enhancing the professionalism and usability of their web applications.
Core dependencies of this npm package and its dev dependencies.
@babel/cli, @babel/core, @babel/node, @babel/preset-env, @babel/preset-react, @mdx-js/react, @storybook/addon-actions, @storybook/addon-docs, @storybook/addon-essentials, @storybook/addon-google-analytics, @storybook/addon-interactions, @storybook/addon-links, @storybook/builder-webpack5, @storybook/manager-webpack5, @storybook/react, @storybook/testing-library, @testing-library/jest-dom, @testing-library/react, @types/jest, @types/react, @types/react-click-outside, @types/react-dom, @typescript-eslint/eslint-plugin, @typescript-eslint/parser, babel-loader, babel-plugin-transform-es2015-modules-umd, coveralls, eslint, eslint-config-prettier, eslint-plugin-jest-dom, eslint-plugin-react, eslint-plugin-storybook, eslint-plugin-testing-library, eslint-plugin-unicorn, fork-ts-checker-webpack-plugin, html-webpack-plugin, jest, jest-environment-jsdom, prettier, react, react-click-outside, react-colorful, react-dom, react-ga4, storybook-dark-mode, ts-jest, ts-loader, typescript, webpack, webpack-cli
A README file for the react-spinners code repository. View Code
A collection of loading spinners with React.js based on Halogen.
This package is bootstraped using react-npm-boilerplate
With Yarn:
yarn add react-spinners
With npm:
npm install --save react-spinners
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
.
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;
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>
);
}
}
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
propcolor
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
propThe 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
propsThe input to these props can be number or string.
px
.px
.The table below has the default values for each loader.
Loader | size | height | width | radius | margin |
---|---|---|---|---|---|
BarLoader | 4 |
100 |
|||
BeatLoader | 15 |
2 |
|||
BounceLoader | 60 |
||||
CircleLoader | 50 |
||||
ClimbingBoxLoader | 15 |
||||
ClipLoader | 35 |
||||
ClockLoader | 50 |
||||
DotLoader | 60 |
2 |
|||
FadeLoader | 15 |
5 |
2 |
2 |
|
GridLoader | 15 |
||||
HashLoader | 50 |
2 |
|||
MoonLoader | 60 |
2 |
|||
PacmanLoader | 25 |
2 |
|||
PropagateLoader | 15 |
||||
PuffLoader | 60 |
||||
PulseLoader | 15 |
2 |
|||
RingLoader | 60 |
2 |
|||
RiseLoader | 15 |
2 |
|||
RotateLoader | 15 |
2 |
|||
ScaleLoader | 35 |
4 |
2 |
2 |
|
SyncLoader | 15 |
2 |