- Notifications
You must be signed in to change notification settings - Fork26
Lightweight SVG/CSS spinners for React
License
adexin/spinners-react
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
9 awesome typescript-aware lightweight spinners built as react.js components.
View demo with examples of react.js component usage.
$ npm install spinners-react
oradd it directly to HTML page
import { SpinnerCircular } from 'spinners-react';<SpinnerCircular />
<SpinnerCircular enabled={false} />
Component | Example | Component | Example | Component | Example |
---|---|---|---|---|---|
SpinnerCircular | SpinnerCircularFixed | SpinnerCircularSplit | |||
SpinnerRound | SpinnerRoundOutlined | SpinnerRoundFilled | |||
SpinnerDotted | SpinnerInfinity | SpinnerDiamond |
The following optional properties are available. All extra props will be passed to the component's root SVG element.
Property | Default value | Type | Description |
---|---|---|---|
size | 50 | number or string | Set the size as number of pixels or any valid CSS string (e.g.size="100%" ). |
thickness | 100 | number | Set lines width as a percentage of default thickness. |
сolor | '#38ad48' | string | Set the color. Can be set to any valid CSS string (hex, rgb, rgba). |
secondaryColor | 'rgba(0,0,0,0.44)' | string | Set the secondary color. Can be set to any valid CSS string (hex, rgb, rgba). |
speed | 100 | number | Set the animation speed as a percentage of default speed. |
enabled | true | boolean | Show/Hide the spinner. |
still | false | boolean | Disable/Enable spinner animation. |
style | undefined | object | Pass CSS styles to the root SVG element |
While the library works with SSR, the spinner's animation CSS will be attached to the head only on thehydrate
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:
/* App.css *//* to load animation for a specific spinner */@import "~spinners-react/lib/SpinnerCircular.css";/* to load animations for all spinners at once */@import "~spinners-react/lib/index.css";
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.If you're using ES6 modules and a bundler that supports tree-shaking you can safely use named imports:
import { SpinnerCircular } from 'spinners-react';
If that's not the case you're able to use path imports to avoid pulling in unused spinners:
// ESMimport { SpinnerCircular } from 'spinners-react/lib/esm/SpinnerCircular';// or CJSconst { SpinnerCircular } = require('spinners-react/lib/cjs/SpinnerCircular');// or UMDconst { SpinnerCircular } = require('spinners-react/lib/umd/SpinnerCircular');
<!doctype html><html> <head> <script src="https://unpkg.com/react@19/umd/react.production.min.js"></script> <script src="https://unpkg.com/react-dom@19/umd/react-dom.production.min.js"></script> <!-- to load a specific spinner --> <script src="https://unpkg.com/spinners-react/lib/umd/SpinnerCircular.min.js"></script> <!-- to load all spinners at once --> <script src="https://unpkg.com/spinners-react/lib/umd/index.min.js"></script> </head> <body> <div></div> <script> ReactDOM.render( React.createElement(SpinnersReact.SpinnerCircular), document.getElementById('root') ); </script> </body></html>
![]() Firefox | ![]() Chrome | ![]() Safari | ![]() Opera | ![]() Edge |
---|---|---|---|---|
last 2 versions | last 2 versions | last 2 versions | last 2 versions | last 2 versions* |
* - Legacy EdgeHTML Edge (i.e. 42-44) is also supported except forSpinnerRound
andSpinnerRoundOutlined
.
Let us know if youfound a bug!
Have a quick question or need some help? Please do not hesitate to contact us via email atinfo@adexin.com.
This component is developed by consulting agencyAdexin.
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.
About
Lightweight SVG/CSS spinners for React
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.