Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A collection of loading spinner components for react

License

NotificationsYou must be signed in to change notification settings

davidhu2000/react-spinners

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

npm versiondownloadslicense

Coverage StatusDependency CountTypes IncludedTree Shaking Supported

A collection of loading spinners with React.js based onHalogen.

This package is bootstraped usingreact-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 aloading prop as a boolean. The loader will rendernull ifloading isfalse.

Example

import{useState,CSSProperties}from"react";import{ClipLoader}from"react-spinners";constoverride:CSSProperties={display:"block",margin:"0 auto",borderColor:"red",};functionApp(){let[loading,setLoading]=useState(true);let[color,setColor]=useState("#ffffff");return(<divclassName="sweet-loading"><buttononClick={()=>setLoading(!loading)}>Toggle Loader</button><inputvalue={color}onChange={(input)=>setColor(input.target.value)}placeholder="Color of the loader"/><ClipLoadercolor={color}loading={loading}cssOverride={override}size={150}aria-label="Loading Spinner"data-testid="loader"/></div>);}exportdefaultApp;
Example using React Class
importReactfrom"react";import{ClipLoader}from"react-spinners";constoverride:React.CSSProperties={display:"block",margin:"0 auto",borderColor:"red",};classAwesomeComponentextendsReact.Component{constructor(props){super(props);this.state={loading:true,};}render(){return(<divclassName="sweet-loading"><ClipLoadercssOverride={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 asaria-* anddata-* 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

ThecssOverride 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, andradius props

The input to these props can benumber orstring.

  • If value is number, the loader will default to css unitpx.
  • 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 topx.

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

[8]ページ先頭

©2009-2025 Movatter.jp