×

Ionic Spinner

The ionic spinner component provides the various SVG (Scalable Vector Graphic) spinners. Ionic spinners are the visual indicators that display the app which is loading content or performing another process that the user needs to wait on.

The default spinner is different for every platform. Such as, the android application has the default spinner “lines”, while the default spinner “crescent” for the iOS application. If the platform neither iOS nor android, then the default spinner will be “crescent”. If the name property is set, then that spinner will be used instead of the platform particular spinner. You can use the <ion-spinner> component to create the spinner in the ionic application.

Example: This example explains how you can use the default spinner in the ionic application.

Home.page.html

<ion-header>  
   <ion-toolbar color="primary">  
     <ion-title>Ionic Spinner Example</ion-title>  
   </ion-toolbar>  
 </ion-header>   
 <ion-content class="ion-padding" color="light">  
   <ion-spinner></ion-spinner>  
 </ion-content>   

Output: After executing this code, you will get the output, which is shown below. Here you can see the default spinner in the ionic application. The default spinner is line.

Ionic Spinner

By using the name property, you can set several types of spinner in the <ion-spinner> component. Such types of the spinner are lines, circles, dots, bubbles, crescent, etc.

Example: This example explains how you can use the different types of the spinner in the ionic application.

Home.page.html

 <ion-header>  
   <ion-toolbar color="primary">  
     <ion-title>Ionic Spinner Example</ion-title>  
   </ion-toolbar>  
 </ion-header>  
 <ion-content fullscreen class="ion-padding" color="light"> 
  <p>Lines</p>  
  <ion-spinner name="lines"></ion-spinner>
  <p>Dots</p>
  <ion-spinner name="dots"></ion-spinner>
  <p>Line small</p>
  <ion-spinner name="lines-small"></ion-spinner> 
  <p>Circles</p>
  <ion-spinner name="circles"></ion-spinner> 
  <p>Bubbles</p>
 <ion-spinner name="bubbles"></ion-spinner>
 <p>Crescent</p>
 <ion-spinner name="crescent"></ion-spinner>
 </ion-content> 

Output: After executing this code, you will get the output, which is shown below. Here can you see the different types of the spinners in the ionic application.

Ionic Spinner2

Setting Time

The Ionic permits the user to set the time duration to the spinner component. It means that when the time you specified is reached, the visual loading indications of the Spinner component will be disappeared.

Example: This example explains how you can set the time in the spinner.

Home.page.html

<ion-header> 
   <ion-toolbar color="primary">  
     <ion-title>Ionic Spinner Example</ion-title>  
   </ion-toolbar>  
 </ion-header>  
 <ion-content class="ion-padding" color="light"> 
  <p>Dots</p>  
   <ion-toolbar color="primary">  
     <ion-title>Ionic Spinner Example</ion-title>  
   </ion-toolbar>  
 </ion-header>  
 <ion-content class="ion-padding" color="light"> 
  <p>Dots</p>
  <ion-spinner name="dots"></ion-spinner> 
  <p >Line small</p>
  <ion-spinner name="lines-small"></ion-spinner> 
  <p>Bubbles</p> 
 <ion-spinner *ngIf="show" name="bubbles" ></ion-spinner>
 <p>Crescent</p>
 <ion-spinner name="crescent"></ion-spinner>
 </ion-content> 

Home.page.ts

In the home.page.ts file, you have to set the time duration to the spinner component.

import { Component } from
'@angular/core';  
 import { AlertController } from '@ionic/angular';  
 @Component({  
   selector: 'app-home',  
   templateUrl: 'home.page.html',  
   styleUrls: ['home.page.scss'],  
 })   
 export class HomePage {  
  show = true;
  constructor(){
    setTimeout(() => {
      this.show = false;
    }, 1500 ); 
    }
  } 

Output: After executing this code, you will get the output, which is shown below.

Ionic Spinner3

When the time limit is reached which you have set, then the bubbles loading spinner will be disappeared, as shown below:

Ionic Spinner4

Pause Spinner

It provides an attribute to the user to pause the animation of the spinner component. By default, the paused attribute is false. If the pause attribute is true, then the spinner animation will be paused. You can set the paused attribute in the <ion-spinner> component.

Example: This example explains how you can set the paused attribute in the spinner component. Here, we have set the paused attribute in the bubble’s spinner.

Home.page.html

<ion-header>  
   <ion-toolbar color="primary">  
     <ion-title>Ionic Spinner Example</ion-title>  
   </ion-toolbar>  
 </ion-header>  
 <ion-content class="ion-padding" color="light">  
   <p>Dots</p>
  <ion-spinner name="dots"></ion-spinner>
  <p >Line small</p>
  <ion-spinner name="lines-small"></ion-spinner> 
  <p>Bubbles</p>
 <ion-spinner name="bubbles" paused></ion-spinner>
 <p>Crescent</p> 
 <ion-spinner name="crescent"></ion-spinner>
 </ion-content> 

Output: After executing this code, you will get the output, which is shown below. Here, you can see that the bubble’s spinner is paused in the application.

Ionic Spinner5

Styling the Spinner

It allows the user to set the different styling or color for the spinner component. You can set the color property in the <ion-spinner> component.

Example: This example explains how you can use the styling or color in the spinner component.

Home.page.html

<ion-header>  
   <ion-toolbar color="primary">  
     <ion-title>Ionic Spinner Example</ion-title>  
   </ion-toolbar>  
 </ion-header>   
 <ion-content class="ion-padding" color="light"> 
   <p>Lines</p>
   <ion-spinner name="lines" color="success"></ion-spinner>
   <p>Dots</p>
  <ion-spinner name="dots" color="primary"></ion-spinner> 
  <p>Line small</p>
  <ion-spinner name="lines-small" color="danger"></ion-spinner> 
  <p>Bubbles</p>
 <ion-spinner name="bubbles" color="dark"></ion-spinner>
 <p>Crescent</p>
 <ion-spinner name="crescent" color="tertiary"></ion-spinner> 
 <p>Circle</p>
 <ion-spinner name="circles" color="warning"></ion-spinner>
 </ion-content> 

Output: After executing this code, you will get the output, which is shown below. Here, you can see the different colors and styles of the spinners.

Ionic Spinner6

Related Topics

Ionic Modal

Ionic modal is displayed as a temporary UI that slides into the screen. The ionic modal is a dialog box that is displayed at the top of the app’s content, and it...

5 minutes read.

Ionic-fab Button

Ionic-fab Button The Ionic FABs (Floating Action Buttons) are standard material design compounds. It is a container element that contains one or more fab buttons. They are required to be placed in a fixed position,...

2 minutes read.

Features of Ionic Framework

The Ionic Framework is based on the AngularJS framework that permits a programmer to use a combination of many other programming languages, like HTML5, CSS, and JavaScript. Some of the...

4 minutes read.

Ionic framework Installation

Installation of Ionic Before proceeding with the ionic application, you'll need to install node.js and NPM (Node Package Manager), the code editor, and Ionic CLI. Installation of node.js and NPM These are the primary...

5 minutes read.

History of Ionic

It is a complete open-source platform for hybrid mobile application development created by Ben Sperry, Max Lynch, and Adam Bradley of Drifty Co. in 2013. The first alpha version of the framework was...

2 minutes read.

Ionic Cards

Ionic Cards: Ionic cards are a standard part of the user interface that acts as an entry point for more specific information. These are the best components for displaying information...

4 minutes read.

Ionic Actionsheet

Ionic Actionsheet The Action sheet is a dialog box that displays a group of options. It is shown on the top of the application content and must be dismissed manually before the user can resume...

3 minutes read.

Ionic Radio

Ionic Radio The radio button is the type of input component that has a Boolean value. The Ionic radio button has a different pattern on every platform, as well as other Ionic components....

2 minutes read.

Ionic vs React Native

Ionic Vs React Native Ionic and React Native are both common framework which is used to develop mobile applications. Here, you will know about the popular differences between the ionic and the React Native. Ionic Ionic...

3 minutes read.

Ionic Buttons

Ionic Buttons There are different types of buttons in the Ionic framework. These buttons are subtly animated, enhancing the user experience when using the application. Buttons are a fundamental way of interacting and navigating...

4 minutes read.

Ionic Loading

The ionic loader is an overlay that can be used to indicate activity, the user interaction while blocking. The ionic loader shows on the top of the app content, and it can...

5 minutes read.

Ionic Segment

A segment is a collection of buttons, sometimes which are known as segmented controls. The segment buttons are displayed at horizontal rows. These segment buttons can be shown in a toolbar or the...

2 minutes read.

Ionic Colors

Ionic Colors Before we start with the actual elements available in the Ionic frame, let's understand a little bit how Ionic uses colors for different elements. Ionic Color Classes Ionic framework is a set of nine predefined...

3 minutes read.

Ionic List

Ionic List The ionic list is created of several rows of items that can contain text, buttons, thumbnails, keys, icons, and more. Lists are one of the essential components in any web or...

4 minutes read.

Ionic Alert

Ionic Alert An Alert is a dialog box that presents the users with important information, or it stores the data from the user by using the inputs. Alerts are a great way to provide...

5 minutes read.

Ionic Refresher

Refresher means updating the currently showing page so that the user can see the latest view. It is also known as re-loading in web technology. It provides a pull- to-refresh feature on a...

4 minutes read.

Ionic progress bar

The ionic progress bar element is a horizontal progress bar used to visualize the progression of operation and activity. You can use the <ion-progress-bar> component to create a progress bar in the ionic...

4 minutes read.

Ionic Menu

The Ionic menu is the side-menu navigation that can be slide in from the side of the current view. By default, the menu slides in from the left side, but the side...

7 minutes read.

Ionic Select

The Ion Selection component is similar to the HTML <select> element. However, the Ionic Selection component makes it easy for users to categorize and choose the preferred option or other options. You must...

3 minutes read.

Difference between Ionic 4 and Ionic 3

The ionic framework is an open-source platform that is used to develop mobile applications. It is also used to build android applications, desktop applications, iOS, and web applications using web technologies like HTML,...

5 minutes read.