Angular Bootstrap Loader / Spinner
Angular loader / spinner - Bootstrap 4 & Material Design
Note: This documentation is for an older version of Bootstrap (v.4). A newer
version is available for Bootstrap 5. We recommend migrating to the latest version of our
product -
Material Design for Bootstrap 5.
Go to docs v.5
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...
.
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
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!
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.
Alignment
Spinners in Bootstrap are built with rem
s, 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.
Placement
Use flexbox utilities, float utilities, or text alignment utilities to place spinners exactly where you need them in any situation.
Flex
Floats
Text align
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.
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.
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>
|
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.
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:
- Add
MDBSpinningPreloader
toapp.module.ts
, -
Configure your
app.component.ts
file by addingMDBSpinningPreloader
service to it, -
Add preloader HTML markup to
index.html
file between<body></body>
tags, above main component (default<app-root></app-root>
).