indreklasn / css-loader

Simple loaders for your web applications using only one div and pure CSS :heart:

Home Page:http://raphaelfabeni.github.io/css-loader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CSS loader

A few simple examples of loaders using only one div and CSS.

loader-g

Try it online! 🀘

Why

It's usually common to show a loader to users when they must wait for something in a web application (an ajax request or a form submit, etc). Gif image loaders were great but by using CSS we can avoid the image request, also it's easier to customise and maintain and it's cooler.

toc

Install

npm install pure-css-loader

Also you can clone the repository or download the zip file and get the main CSS file that is located in: dist/css-loader.css.

Setup

Add the CSS file to your project and add the link to the file:

<link rel="stylesheet" href="path/to/css-loader.css">

Select the loader and add the corresponding HTML. In order to show the loader, you need to add the helper CSS class is-active. And to hide the loader, just do the opposite, removing the CSS helper from the loader. You can do it with JavaScript.

<!-- Loader -->
<div class="loader loader-default"></div>

<!-- Loader active -->
<div class="loader loader-default is-active"></div>

Examples

Default

<div class="loader loader-default is-active"></div>

loader

See it 🀘

Variations

data-text: add a Loading text to the loader. Just add the data-text attribute.

<div class="loader loader-default is-active" data-text></div>

loader-data-text

See it 🀘

It's also possible to change the text, just passing a value to the attribute data-text.

<div class="loader loader-default is-active" data-text="Custom text"></div>

loader-data-text-custom

blink: passing the blink attribute, you can add a simple fade animation to the text loader

<div class="loader loader-default is-active" data-text blink></div>

loader-blink

See it 🀘

half: a half loader.

loader-half

See it 🀘

The variations half, data-text and blink work together. πŸ˜„

Double

<div class="loader loader-double is-active"></div>

loader-double

See it 🀘

Bar

<div class="loader loader-bar is-active"></div>

loader-bar

See it 🀘

Variations

Like the loader example, it's also possible to pass the data-text and blink attributes.

<div class="loader loader-bar is-active" data-text></div>
<!-- -->
<div class="loader loader-bar is-active" data-text="Custom text"></div>
<!-- -->
<div class="loader loader-bar is-active" data-text blink></div>

See it 🀘

rounded: passing the rounded attribute, it's possible to add a simple border-radius to the loader.

loader-bar-rounded

<div class="loader loader-bar is-active" data-text rounded></div>

See it 🀘

Border

loader-border

<div class="loader loader-border is-active"></div>

See it 🀘

Variations

Like the loader example, it's also possible to pass the data-text and blink attributes.

<div class="loader loader-border is-active" data-text></div>
<!-- -->
<div class="loader loader-border is-active" data-text="Custom text"></div>
<!-- -->
<div class="loader loader-border is-active" data-text blink></div>

See it 🀘

Ball

<div class="loader loader-ball is-active"></div>

loader-ball

See it 🀘

Variations

shadow: a version of the ball with inset shadow.

loader-ball-shadow

See it 🀘

Smartphone

<div class="loader loader-smartphone is-active"></div>

loader-smartphone-empty

See it 🀘

Variations

w/ screen text: it's possible to pass an attribute to the loader and show a simple text inside the screen. Like the other one, if we only pass the attribute, a default loading text is shown; but you can pass a custom text. Just remember that it can't be a big word (our smartphone screen is small).

<!-- default loading text -->
<div class="loader loader-smartphone is-active" data-screen></div>

<!-- custom text -->
<div class="loader loader-smartphone is-active" data-screen="hello"></div>

loader-smartphone

See it 🀘

Clock

<div class="loader loader-clock is-active"></div>

loader-clock

See it 🀘

Contributing

  1. Clone this repository.
  2. npm install and gulp
  3. Open => http://localhost:3000
  4. Make your magic contribution.
  5. Open a PR with a new branch describing your changes. <o/

Browser Support

All examples use CSS animation which is supported by most current browsers.

Chrome logo Firefox logo Internet Explorer logo Opera logo Safari logo Android Browser Logo
43+ βœ” 16+ βœ” 10+ βœ” 30+ βœ” 9+ βœ” 5.2+ βœ”

Based on Can i Use. One thing to note is that the CSS file has no browser prefixes, but you can easily add them and increase the browser support.

License

MIT License Β© Raphael Fabeni

About

Simple loaders for your web applications using only one div and pure CSS :heart:

http://raphaelfabeni.github.io/css-loader


Languages

Language:CSS 88.4%Language:JavaScript 11.6%