Open In App

Angular PrimeNG ProgressSpinner Custom

Last Updated : 23 Aug, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will see how to use the ProgressSpinner Custom in Angular PrimeNG. We will also learn about the properties along with their syntaxes that will be used in the code.

The ProgressSpinner component is used to make a spinner that illustrates the process status.

Syntax:

<p-progressSpinner
    [style]="{...}"
    strokeWidth="..."
    fill="..."
    animationDuration="...">
</p-progressSpinner>

Angular PrimeNG ProgressSpinner Custom properties:

  • strokeWidth: It specifies the width of the circle stroke. It accepts a string data type as input & the default value is 2.
  • fill: It specifies the color for the background of the circle. It is of string data type, the default value is null.
  • animationDuration: It specifies the duration of the rotate animation. It is of string data type, the default value is 2s.

Creating Angular application & module  installation:

Step 1: Create an Angular application using the following command.

ng new appname

Step 2: After creating your project folder i.e. app name, move to it using the following command.

cd appname

Step 3: Install PrimeNG in your given directory.

npm install primeng --save
npm install primeicons --save

Project Structure: After complete installation, it will look like the following:

 

  • Run the below command to see the output:
ng serve --open

Example 1: Below is the example code that illustrates the use of Angular PrimeNG ProgressSpinner Custom.

app.component.html




<div style="text-align: center">
    <h2 style="color: green">GeeksforGeeks</h2>
    <h5>Angular PrimeNG ProgressSpinner Custom</h5>
  
    <p-progressSpinner
      [style]="{ width: '100px', height: '100px' }"
      styleClass="custom-spinner"
      strokeWidth="5"
      fill="lightgreen"
      animationDuration=".3s">
    </p-progressSpinner>
</div>


app.component.ts




import { Component } from '@angular/core';
  
@Component({
   selector: 'app-root',
   templateUrl: './app.component.html',
   styleUrls: ['app.component.scss']
})
export class AppComponent {}


app.module.ts




import { BrowserAnimationsModule } 
    from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { ProgressSpinnerModule } 
    from 'primeng/progressspinner';
  
@NgModule({
  imports: [
    BrowserAnimationsModule,
    ProgressSpinnerModule,
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}


Output:

 

Example 2: Below is another example code that illustrates Angular PrimeNG ProgressSpinner Custom using some other custom property values.

app.component.html




<div style="text-align: center">
    <h2 style="color: green">GeeksforGeeks</h2>
    <h5>Angular PrimeNG ProgressSpinner Custom</h5>
  
    <p-progressSpinner
        [style]="{ width: '75px', height: '75px' }"
        strokeWidth="10"
        fill="yellow"
        animationDuration="2s">
    </p-progressSpinner>
</div>


app.component.ts




import { Component } from '@angular/core';
  
@Component({
   selector: 'app-root',
   templateUrl: './app.component.html',
   styleUrls: ['app.component.scss']
})
export class AppComponent {}


app.module.ts




import { BrowserAnimationsModule } 
   from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { ProgressSpinnerModule } 
   from 'primeng/progressspinner';
  
@NgModule({
 imports: [
   BrowserAnimationsModule,
   ProgressSpinnerModule,
 ],
 declarations: [AppComponent],
 bootstrap: [AppComponent],
})
export class AppModule{}


Output:

 

Reference: https://primefaces.org/primeng/progressspinner



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads