Edit these docs Rate these docs

Angular Bootstrap Loader / Spinner

Angular loader / spinner - Bootstrap 4 & Material Design

Preloaders (also known as loaders) are simple animations that are used to keep visitors entertained while the page is still loading, which helps to increase the user experience.

Angular Bootstrap “spinners” can be used to show the loading state in your projects. They’re built only with HTML and CSS, meaning you don’t need any JavaScript to create them. You will, however, need some custom JavaScript to toggle their visibility. Their appearance, alignment, and sizing can be easily customized with our amazing utility classes.

For accessibility purposes, each loader here includes role="status" and a nested Loading....


Default loader

Use the border spinners for a lightweight loading indicator.

Loading...


            <div class="spinner-border" role="status">
              <span class="sr-only">Loading...</span>
            </div>

          

Material loader MDB Pro component

Material Design styling for Bootstrap Loader component



            <mdb-spinner spinnerColor="blue"></mdb-spinner>

          

Loader colors

The default spinner uses currentColor for its border-color, meaning you can customize the color with text color utilities. You can use any of our text color utilities on the standard spinner.

Default loader

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...


            <div class="spinner-border text-primary" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-border text-secondary" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-border text-success" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-border text-danger" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-border text-warning" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-border text-info" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-border text-light" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-border text-dark" role="status">
              <span class="sr-only">Loading...</span>
            </div>

          

Material loader MDB Pro component



            <mdb-spinner spinnerColor="red"></mdb-spinner>
            <mdb-spinner spinnerColor="blue"></mdb-spinner>
            <mdb-spinner spinnerColor="yellow"></mdb-spinner>
            <mdb-spinner spinnerColor="green"></mdb-spinner>
            <mdb-spinner></mdb-spinner>


          

Why not use border-color utilities? Each border spinner specifies a transparent border for at least one side, so .border-{color} utilities would override that.


Growing spinner

If you don’t fancy a border spinner, switch to the grow spinner. While it doesn’t technically spin, it does repeatedly grow!

Loading...


            <div class="spinner-grow" role="status">
              <span class="sr-only">Loading...</span>
            </div>

          

Once again, this spinner is built with currentColor, so you can easily change its appearance with text color utilities. Here it is in blue, along with the supported variants.

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...


            <div class="spinner-grow text-primary" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-grow text-secondary" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-grow text-success" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-grow text-danger" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-grow text-warning" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-grow text-info" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-grow text-light" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-grow text-dark" role="status">
              <span class="sr-only">Loading...</span>
            </div>

          

Alignment

Spinners in Bootstrap are built with rems, currentColor, and display: inline-flex. This means they can easily be resized, recolored, and quickly aligned.

Margin

Use margin utilities like .m-5 for easy spacing.

Loading...


        <div class="spinner-border m-5" role="status">
          <span class="sr-only">Loading...</span>
        </div>

      

Placement

Use flexbox utilities, float utilities, or text alignment utilities to place spinners exactly where you need them in any situation.

Flex

Loading...


        <div class="d-flex justify-content-center">
          <div class="spinner-border" role="status">
            <span class="sr-only">Loading...</span>
          </div>
        </div>

      
Loading...


        <div class="d-flex align-items-center">
          <strong>Loading...</strong>
          <div class="spinner-border ml-auto" role="status" aria-hidden="true"></div>
        </div>

      

Floats

Loading...


        <div class="clearfix">
          <div class="spinner-border float-right" role="status">
            <span class="sr-only">Loading...</span>
          </div>
        </div>

      

Text align

Loading...


        <div class="text-center">
          <div class="spinner-border" role="status">
            <span class="sr-only">Loading...</span>
          </div>
        </div>

      

Loader sizing

You can set different sizes of loader, both default and material ones.

For default spinner add .spinner-border-sm and .spinner-grow-sm to make a smaller spinner that can quickly be used within other components or, use custom CSS or inline styles to change the dimensions as needed.

Default loader

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...


            <div class="spinner-border spinner-border-sm" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-grow spinner-grow-sm" role="status">
              <span class="sr-only">Loading...</span>
            </div>

            <div class="spinner-border" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-grow" role="status">
              <span class="sr-only">Loading...</span>
            </div>

            <div class="spinner-border" style="width: 3rem; height: 3rem;" role="status">
              <span class="sr-only">Loading...</span>
            </div>
            <div class="spinner-grow" style="width: 3rem; height: 3rem;" role="status">
              <span class="sr-only">Loading...</span>
            </div>

          

Material loader MDB Pro component



            <mdb-spinner spinnerType="big" spinnerColor="blue"></mdb-spinner>
            <mdb-spinner spinnerColor="blue"></mdb-spinner>
            <mdb-spinner spinnerType="small" spinnerColor="blue"></mdb-spinner>


          

Buttons

Use spinners within buttons to indicate an action is currently processing or taking place. You may also swap the text out of the spinner element and utilize button text as needed.

Default loader



            <button mdbBtn color="primary" type="button" disabled>
              <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
              <span class="sr-only">Loading...</span>
            </button>
            <button mdbBtn color="primary" type="button" disabled>
              <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
              Loading...
            </button>

          


            <button mdbBtn color="primary" type="button" disabled>
              <span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
              <span class="sr-only">Loading...</span>
            </button>
            <button mdbBtn color="primary" type="button" disabled>
              <span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
              Loading...
            </button>


          

Install MDB CLI
It's the fastest way to create and host MDB projects
Free Download

Edit these docs Rate these docs

Angular Loaders - API

In this section you will find informations about required modules and available inputs of loaders component.


Modules used

In order to speed up your application, you can choose to import only the modules you actually need, instead of importing the entire MDB Angular library. Remember that importing the entire library, and immediately afterwards a specific module, is bad practice, and can cause application errors.

// MDB Angular Pro
import { WavesModule, PreloadersModule } from 'ng-uikit-pro-standard'

Components

ProgressSpinnerComponent

Selector: mdb-spinner

Type: ProgressSpinnerComponent


Inputs

ProgressSpinnerComponent
Name Type Default Description Example
spinnerType string ' ' Allow to set size of a spinner. Values are big and small. spinnerType="small"
spinnerColor string rainbow Allow to set color of a spinner. Values are green, blue, yellow, red, rainbow. spinnerColor="red"

Below classes can be used in spinner loader component (circles).

Name Type Usage
.spinner-blue color class <div class="spinner-layer spinner-blue"></div>
.spinner-red color class <div class="spinner-layer spinner-red"></div>
.spinner-yellow color class <div class="spinner-layer spinner-yellow"></div>
.spinner-green color class <div class="spinner-layer spinner-green"></div>
.spinner-primary-color color class <div class="spinner-layer spinner-primary-color"></div>
.*-only color class prefix <div class="spinner-layer spinner-primary-color-only"></div>
.small size class <div class="preloader-wrapper small active"></div>
(blank) - default size size class <div class="preloader-wrapper active"></div>
.big size class <div class="preloader-wrapper big active"></div>
Edit these docs Rate these docs

Angular Loader - examples & customization

Examples of using preloaders in real cases.


Preloader with application version checking MDB Pro component

Simple example showing, how could you use our preloaders in your real application.


        <div class="row">
          <div class="col-12">
            <div class="my-5" *ngIf="!visible">
              <h3 class="h3-responsive text-center">Your version is up to date.</h3>
              <h5 class="h5responsive text-center">Last update check on:
                {{today}}
              </h5>
            </div>

            <div class="view" *ngIf="visible" style="height:100vh; width:100vw; position:fixed; top:0; left:0; z-index:999">
              <div class="mask rgba-black-strong flex-center">
                <p class="white-text">Comparing versions...</p>
                <br>
                <mdb-spinner spinnerType="big"></mdb-spinner>
              </div>
            </div>
          </div>
        </div>
      

        import { Component, OnInit } from '@angular/core';

        @Component({
        selector: 'preloader-usage',
        templateUrl: './preloader-usage.component.html',
        styleUrls: ['./preloader-usage.component.scss']
        })
        export class PreloaderUsageComponent implements OnInit {
        visible: boolean = true;
        date = new Date();
        today = this.date.getDate() + '/' + (this.date.getMonth() + 1) + '/' + this.date.getFullYear();

        ngOnInit() {
        setTimeout(() => {
        this.visible = false;
        }, 3000);

        }
        }
      

Preloading script MDB Pro component

An example showing how to use the preloader in the ngOnInit cycle.

Usage

Adding preloader to your project


In order to have working preloaders on every component in your project, you need to perform those 3 steps:

  1. Add MDBSpinningPreloader to app.module.ts,
  2. Configure your app.component.ts file by adding MDBSpinningPreloader service to it,
  3. Add preloader HTML markup to index.html file between <body></body> tags, above main component (default <app-root></app-root>).

1st step - app.module.ts

import { MDBSpinningPreloader } from 'ng-uikit-pro-standard';

@NgModule({
...
providers: [MDBSpinningPreloader],
...
})

  
2nd step - app.component.ts

import { Component, OnInit } from '@angular/core';
import {MDBSpinningPreloader} from 'ng-uikit-pro-standard';
@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html'
})

export class AppComponent implements OnInit {
  constructor(private mdbSpinningPreloader: MDBSpinningPreloader) {}

  ngOnInit() {
    this.mdbSpinningPreloader.stop();
  }
}
  
3rd step - index.html

<div class="spinning-preloader-container">
<div class="preloader-wrapper big active">

<div class="spinner-layer spinner-blue">
  <div class="circle-clipper left">
    <div class="circle"> </div>
  </div> <div class="gap-patch">
    <div class="circle"> </div>
  </div>
</div>

<div class="spinner-layer spinner-red">
  <div class="circle-clipper left">
    <div class="circle"> </div>
  </div> <div class="gap-patch">
    <div class="circle"> </div>
  </div>
</div>

<div class="spinner-layer spinner-yellow">
  <div class="circle-clipper left">
    <div class="circle"> </div>
  </div> <div class="gap-patch">
    <div class="circle"> </div>
  </div>
</div>

<div class="spinner-layer spinner-green">
  <div class="circle-clipper left">
    <div class="circle"> </div>
  </div> <div class="gap-patch">
    <div class="circle"> </div>
  </div>
</div>

</div>
</div>