0.4.7 • Published 5 years ago

react-animdemo2 v0.4.7

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

React Spinners

npm version circle ci downloads license Code Triagers Badge

dependencies Status devDependencies Status peerDependencies Status

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

This package is bootstraped using react-npm-boilerplate

Demo

Demo Page

Installation

npm install react-spinners --save

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 not render anything if loading is false. The loading prop defaults to true.

IMPORTANT: This package uses emotion. Remember to add the plugin to .babelrc, for example:

{
    "presets": ["react", "env"],
    "plugins": ["emotion"]
}

Examples

import React from 'react';
import { css } from 'react-emotion';
// First way to import
import { ClipLoader } from 'react-spinners';
// Another way to import
import ClipLoader from 'react-spinners/ClipLoader';

const override = css`
    display: block;
    margin: 0 auto;
    border-color: red;
`;

class AwesomeComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      loading: true
    }
  }
  render() {
    return (
      <div className='sweet-loading'>
        <ClipLoader
          className={override}
          sizeUnit={"px"}
          size={150}
          color={'#123abc'}
          loading={this.state.loading}
        />
      </div> 
    )
  }
}

Available Loaders, PropTypes, and Default Values

Common default props for all loaders:

loading: true
color: '#000000'
className: ''

Note: className works exactly like the className works with the emotion package. You can directly write your css in css syntax without the dirty camelCase css in jss syntax. We recommend you to use this awesome library in your project. It supports Server side rendering with HTTP2 Stream! More info about using className here

For size, height, and width props, there are sizeUnit, heightUnit, and widthUnit prop that accepts px, %, or em. The default for the unit prop is px.

Loadersize:intheight:intwidth:intradius:intmargin:str
BarLoader4100
BeatLoader152px
BounceLoader60
CircleLoader50
ClipLoader35
ClimbingBoxLoader15
DotLoader602px
FadeLoader15522px
GridLoader15
HashLoader502px
MoonLoader602px
PacmanLoader252px
PropagateLoader15
PulseLoader152px
RingLoader602px
RiseLoader152px
RotateLoader152px
ScaleLoader35422px
SyncLoader152px