Simple loading spinners animated with CSS. Seedemo.SpinKit only uses (transform
andopacity
) CSS animations to create smooth and easily customizable animations.
- Add
spinkit.css
orspinkit.min.css
to your project (or copy-paste the CSS that you need for your spinner—there are no dependencies between spinners, no shared classes, and no shared animations, etc, so it should be fairly straight-forward to extract only the code that you need) - Add a spinner to your project by copy-pasting HTML from
spinkit.css
orexamples.html
- Add the
sk-center
utility class to the spinner to center it (it setsmargin
toauto
) - By default, the
width
andheight
of all spinners are set to40px
.background-color
is set to#333
. - Configure the spinner by overwriting the CSS variables, primarily
--sk-size
(spinner width & height) and--sk-color
(spinner color). If you need broader browser support, remove the CSS variables.
You can include SpinKit to your project withbower
:
$ bower install spinkit
or npm:
$ npm install spinkit
Given that you have includedspinkit.min.css
in your project, these snippets will produce the different spinners:
<divclass= "sk-plane"></div>
<divclass= "sk-chase">
<divclass= "sk-chase-dot"></div>
<divclass= "sk-chase-dot"></div>
<divclass= "sk-chase-dot"></div>
<divclass= "sk-chase-dot"></div>
<divclass= "sk-chase-dot"></div>
<divclass= "sk-chase-dot"></div>
</div>
<divclass= "sk-bounce">
<divclass= "sk-bounce-dot"></div>
<divclass= "sk-bounce-dot"></div>
</div>
<divclass= "sk-wave">
<divclass= "sk-wave-rect"></div>
<divclass= "sk-wave-rect"></div>
<divclass= "sk-wave-rect"></div>
<divclass= "sk-wave-rect"></div>
<divclass= "sk-wave-rect"></div>
</div>
<divclass= "sk-pulse"></div>
<divclass= "sk-flow">
<divclass= "sk-flow-dot"></div>
<divclass= "sk-flow-dot"></div>
<divclass= "sk-flow-dot"></div>
</div>
<divclass= "sk-swing">
<divclass= "sk-swing-dot"></div>
<divclass= "sk-swing-dot"></div>
</div>
<divclass= "sk-circle">
<divclass= "sk-circle-dot"></div>
<divclass= "sk-circle-dot"></div>
<divclass= "sk-circle-dot"></div>
<divclass= "sk-circle-dot"></div>
<divclass= "sk-circle-dot"></div>
<divclass= "sk-circle-dot"></div>
<divclass= "sk-circle-dot"></div>
<divclass= "sk-circle-dot"></div>
<divclass= "sk-circle-dot"></div>
<divclass= "sk-circle-dot"></div>
<divclass= "sk-circle-dot"></div>
<divclass= "sk-circle-dot"></div>
</div>
<divclass= "sk-circle-fade">
<divclass= "sk-circle-fade-dot"></div>
<divclass= "sk-circle-fade-dot"></div>
<divclass= "sk-circle-fade-dot"></div>
<divclass= "sk-circle-fade-dot"></div>
<divclass= "sk-circle-fade-dot"></div>
<divclass= "sk-circle-fade-dot"></div>
<divclass= "sk-circle-fade-dot"></div>
<divclass= "sk-circle-fade-dot"></div>
<divclass= "sk-circle-fade-dot"></div>
<divclass= "sk-circle-fade-dot"></div>
<divclass= "sk-circle-fade-dot"></div>
<divclass= "sk-circle-fade-dot"></div>
</div>
<divclass= "sk-grid">
<divclass= "sk-grid-cube"></div>
<divclass= "sk-grid-cube"></div>
<divclass= "sk-grid-cube"></div>
<divclass= "sk-grid-cube"></div>
<divclass= "sk-grid-cube"></div>
<divclass= "sk-grid-cube"></div>
<divclass= "sk-grid-cube"></div>
<divclass= "sk-grid-cube"></div>
<divclass= "sk-grid-cube"></div>
</div>
<divclass= "sk-fold">
<divclass= "sk-fold-cube"></div>
<divclass= "sk-fold-cube"></div>
<divclass= "sk-fold-cube"></div>
<divclass= "sk-fold-cube"></div>
</div>
<divclass= "sk-wander">
<divclass= "sk-wander-cube"></div>
<divclass= "sk-wander-cube"></div>
<divclass= "sk-wander-cube"></div>
</div>
SpinKit uses CSS animations and variables:
- CSS keyframes animationsare at +96.5% global support
- CSS variablesare at +91.8% global support
How do you know if you need to provide a fallback? You can check for animation support withModernizr,or manually check for theanimation
property, and replace the spinner with a GIF if it's not supported:
functionbrowserSupportsCSSProperty(propertyName){
varelm=document.createElement('div');
propertyName=propertyName.toLowerCase();
if(elm.style[propertyName]!=undefined)
returntrue;
varpropertyNameCapital=propertyName.charAt(0).toUpperCase()+propertyName.substr(1),
domPrefixes='Webkit Moz ms O'.split(' ');
for(vari=0;i<domPrefixes.length;i++){
if(elm.style[domPrefixes[i]+propertyNameCapital]!=undefined)
returntrue;
}
returnfalse;
}
Use it to check foranimation
support:
if(!browserSupportsCSSProperty('animation')){
// fallback…
}