|
| 1 | +# Spinners React |
| 2 | +[](http://npm.im/spinners-react) [](https://travis-ci.org/adexin/spinners-react) [](https://coveralls.io/github/adexin/spinners-react?branch=master) [](https://unpkg.com/spinners-react/lib/umd/index.min.js) |
| 3 | + |
| 4 | + |
| 5 | +9 awesome typescript-aware lightweight spinners built as react.js components. |
| 6 | + |
| 7 | +<p align="center"> |
| 8 | + <a href="http://adexin.github.io/spinners"> |
| 9 | + <img src="https://i.imgur.com/xa7eWLW.gif" /> |
| 10 | + </a> |
| 11 | +</p> |
| 12 | + |
| 13 | +## Demo |
| 14 | +[View demo](https://adexin.github.io/spinners/) with examples of react.js component usage. |
| 15 | + |
| 16 | +## Getting started |
| 17 | +### Installation |
| 18 | +``` |
| 19 | +$ npm install spinners-react |
| 20 | +``` |
| 21 | +**or** [add it directly to HTML page](#UMD-bundle-usage) |
| 22 | + |
| 23 | +### Usage |
| 24 | +``` |
| 25 | +import { SpinnerCircular } from 'spinners-react'; |
| 26 | +
|
| 27 | +<SpinnerCircular /> |
| 28 | +``` |
| 29 | + |
| 30 | +### Hide spinner |
| 31 | +``` |
| 32 | +<SpinnerCircular enabled={false} /> |
| 33 | +``` |
| 34 | + |
| 35 | +### List of components |
| 36 | + |
| 37 | +| Component | Example | Component | Example | Component | Example | |
| 38 | +|-----------|---------|-----------|---------|-----------|---------| |
| 39 | +|`SpinnerCircular`|<img width="70" src="https://i.imgur.com/o89jDAP.gif" />|`SpinnerCircularFixed`| <img width="70" src="https://i.imgur.com/tTAGJCm.gif" />|`SpinnerCircularSplit`| <img width="70" src="https://i.imgur.com/bnmc9Ww.gif" />| |
| 40 | +|`SpinnerRound` |<img width="70" src="https://i.imgur.com/ankNNb4.gif" />|`SpinnerRoundOutlined`|<img width="70" src="https://i.imgur.com/EGAQ1zI.gif" />|`SpinnerRoundFilled` |<img width="70" src="https://i.imgur.com/izh0T8z.gif" />| |
| 41 | +|`SpinnerDotted` |<img width="70" src="https://i.imgur.com/PRsEM0Y.gif" />|`SpinnerInfinity` |<img width="70" src="https://i.imgur.com/gdvE3yw.gif" />|`SpinnerRomb` |<img width="70" src="https://i.imgur.com/P2lUfRy.gif" />| |
| 42 | + |
| 43 | +## Properties |
| 44 | +The following optional properties are available. All extra props will be passed to the component's root SVG element. |
| 45 | + |
| 46 | +| Property | Default value | Type | Description | |
| 47 | +|----------|---------------|----------------|-------------| |
| 48 | +|size |`50` |number or string|Set the size as number of pixels or any valid CSS string (e.g. `size="100%"`).| |
| 49 | +|thickness |`100` |number |Set lines width as a percentage of default thickness.| |
| 50 | +|сolor |`#38ad48` |string |Set the color. Can be set to any valid CSS string (hex, rgb, rgba).| |
| 51 | +|speed |`100` |number |Set the animation speed as a percentage of default speed.| |
| 52 | +|enabled |`true` |boolean |Show/Hide the spinner.| |
| 53 | +|still |`false` |boolean |Disable/Enable spinner animation.| |
| 54 | +|style |undefined |object |Pass CSS styles to the root SVG element| |
| 55 | + |
| 56 | +## Server Side Rendering |
| 57 | +While the library works with SSR, the spinner's animation CSS will be attached to the head only on the ```hydrate``` phase, which means the spinners will start animating only after the page is fully loaded. To work around this, include the needed css in your bundle.css manually: |
| 58 | +``` |
| 59 | +/* App.css */ |
| 60 | +
|
| 61 | +/* to load animation for a specific spinner */ |
| 62 | +@import "~spinners-react/lib/SpinnerCircular.css"; |
| 63 | +
|
| 64 | +/* to load animations for all spinner at once */ |
| 65 | +@import "~spinners-react/lib/index.css"; |
| 66 | +``` |
| 67 | + |
| 68 | +## Minimizing Bundle Size |
| 69 | +The library is thin and do not rely on any style library / runtime to be used. To reduce the bundle size even more load only the used components. |
| 70 | +If you're using ES6 modules and a bundler that supports tree-shaking you can safely use named imports: |
| 71 | +``` |
| 72 | +import { SpinnerCircular } from 'spinners-react'; |
| 73 | +``` |
| 74 | +It that's not the case you're able to use path imports to avoid pulling in unused spinners: |
| 75 | +``` |
| 76 | +// ESM |
| 77 | +import { SpinnerCircular } from 'spinners-react/lib/esm/SpinnerCircular'; |
| 78 | +// or CJS |
| 79 | +import { SpinnerCircular } from 'spinners-react/lib/cjs/SpinnerCircular'; |
| 80 | +// or UMD |
| 81 | +import { SpinnerCircular } from 'spinners-react/lib/umd/SpinnerCircular'; |
| 82 | +
|
| 83 | +``` |
| 84 | + |
| 85 | +## UMD bundle usage |
| 86 | +``` |
| 87 | +<!doctype html> |
| 88 | +<html> |
| 89 | + <head> |
| 90 | + <script src="https://unpkg.com/react@16/umd/react.production.min.js"></script> |
| 91 | + <script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script> |
| 92 | + <!-- to load a specific spinner --> |
| 93 | + <script src="https://unpkg.com/spinners-react/lib/umd/SpinnerCircular.min.js"></script> |
| 94 | + <!-- to load all spinners at once --> |
| 95 | + <script src="https://unpkg.com/spinners-react/lib/umd/index.min.js"></script> |
| 96 | + </head> |
| 97 | +
|
| 98 | + <body> |
| 99 | + <div id="root"></div> |
| 100 | + <script> |
| 101 | + ReactDOM.render( |
| 102 | + React.createElement(SpinnersReact.SpinnerCircular), |
| 103 | + document.getElementById('root') |
| 104 | + ); |
| 105 | + </script> |
| 106 | + </body> |
| 107 | +</html> |
| 108 | +``` |
| 109 | + |
| 110 | +## Browsers support |
| 111 | + |
| 112 | +| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br> Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Opera | |
| 113 | +| --------- | --------- | --------- | --------- | --------- | |
| 114 | +| Edge 80+| last 2 versions| last 2 versions| last 2 versions| last 2 versions |
| 115 | + |
| 116 | +## Issues and Bugs |
| 117 | + |
| 118 | +Let us know if you [found a bug](https://github.com/adexin/spinners-react/issues)! |
| 119 | + |
| 120 | +## Support and Contact |
| 121 | + |
| 122 | +Have a quick question or need some help? Please do not hesitate to contact us via email at info@adexin.com. |
| 123 | + |
| 124 | +## Credits |
| 125 | + |
| 126 | +This component is developed by consulting agency [Adexin](https://adexin.com/). |
| 127 | + |
| 128 | +## License |
| 129 | + |
| 130 | +Spinners React is released under MIT license. You are free to use, modify and distribute this software, as long as the copyright header is left intact. |
0 commit comments