×

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 Navigation and Routing

The latest version (ionic 4) of the ionic framework, no longer limited to the angular. In Ionic 4, you can create an ionic project in different front-end frameworks such as Vue.js, React.js, and...

6 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.

Ionic vs PhoneGap

Ionic Vs PhoneGap Ionic and PhoneGap are both used to develop the mobile application. Both Frameworks are used in large enterprises by the developers. Here, we are going to compare the important differences between ionic...

3 minutes read.

Ionic Range

The Range slider lets users choose from a range of values by moving the slider knob. You can accept two knobs, but by default, one-knob controls the range value. Range labels You can put down on...

2 minutes read.

Ionic Reorder

The Ionic offers the <ion-reorder> component to reordering features. Ionic reorder component adds the Drag and Drop feature to list items, in which the user can change the order of the items. Reorder...

3 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 Chip

Ionic chip displays the complex entities in small entities in small blocks, such as the contacts. Ionic chip has several types of elements like avatars, thumbnails, text, and icons. It is a bubble-like...

3 minutes read.

Ionic Date Time

Ionic Date Time The DateTime component is used to display an interface that makes it simple for users to select dates and times. Tapping on <ion-datetime> will display a slider up from the...

4 minutes read.

Ionic Popover

The Ionic popover is a small dialog box that displays at the top of the screen. It can be used for anything, but it is usually used for a button, an action,...

4 minutes read.

Ionic Infinite Scroll

The infinite scroll permits you to perform an action when the user scrolls a particular content from the bottom or top of the page. When you display the large collection of data...

3 minutes read.

Ionic Input

Ionic Input Inputs are necessary to collect and process user inputs securely. To be easy for users to communicate, they must follow the process and communication guidelines for each platform. It is a...

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 Contents

Ionic Contents The content component provides an easy-to-use content area with some useful ways to control the scrollable region. There should be only one content in one view. Content, along with several other Ionic...

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 vs Apache Cordova

Ionic Vs Apache Cordova Ionic and Cordova are two popular technology going on in the market for mobile application development. The combination of these two technologies creates a development platform that is known as...

3 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 Checkbox

Ionic Checkbox Ionic Checkbox is nearly the same as a toggle. It can be placed in an ionic element or used as a separate checkbox. It is designed differently for every platform, such...

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.

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 Slides

The ionic slides component is the multi-section container. You can swipe or drag any segment between them. This contains any number of slides components. Slides help it easy to make galleries, tutorials, and...

2 minutes read.