Open In App

<mat-progress-bar> in Angular Material

Improve
Improve
Like Article
Like
Save
Share
Report

Introduction:

Angular Material is a UI component library that is developed by the Angular team to build design components for desktop and mobile web applications. In order to install it, we need to have angular installed in our project, once you have it you can enter the below command and can download it. <mat-progress-bar> tag is used for displaying the progress bar. Progress bars are used to indicate the status of a particular task.

Installation syntax:

ng add @angular/material

Approach:

  • First, install the angular material using the above-mentioned command.
  • After completing the installation, Import ‘MatProgressBarModule’ from ‘@angular/material/progress-bar’ in the app.module.ts file.
  • To use progress bars we need to simply use <mat-progress-bar> tag.
  • They are many types of progress bars like determinate, indeterminate, buffer and etc.
  • In-order to show the progress we need to give a value property to the tag.
  • If we want to change the theme then we can change it by using the color property. In angular we have 3 themes, they are primary, accent, and warn.
  • Once done with the above steps then serve or start the project.

Code Implementation:

app.module.ts:

Javascript




import { CommonModule } from '@angular/common'
import { NgModule } from '@angular/core'
import { FormsModule } from '@angular/forms'
import { MatProgressBarModule } from '@angular/material'
    
import { AppComponent } from './example.component'
    
@NgModule({ 
  declarations: [AppComponent], 
  exports: [AppComponent], 
  imports: [ 
    CommonModule, 
    FormsModule, 
    MatProgressBarModule
  
  ], 
}) 
export class AppModule {}


app.component.html:

HTML




<h4> Progress Bars with primary theme </h4>
  
<mat-progress-bar mode="determinate" 
    value="40"></mat-progress-bar>
<br><br><br>
  
<mat-progress-bar mode="buffer" 
    value="40"></mat-progress-bar>
<br><br><br>
  
<mat-progress-bar mode="indeterminate" 
    value="40"></mat-progress-bar>
  
<h4> Progress Bars with warn theme </h4>
<mat-progress-bar mode="determinate" 
    value="40" color="warn"></mat-progress-bar>
<br><br><br>
  
<mat-progress-bar mode="buffer" value="40" 
    color="warn"></mat-progress-bar>
<br><br><br>
  
<mat-progress-bar mode="indeterminate" 
    value="40" color="warn"></mat-progress-bar>
<br><br><br>
  
<h4> Progress Bars with accent theme </h4>
  
<mat-progress-bar mode="determinate" value="40"
        color="accent"></mat-progress-bar>
<br><br><br>
  
<mat-progress-bar mode="buffer" value="40" 
    color="accent"></mat-progress-bar>
<br><br><br>
  
<mat-progress-bar mode="indeterminate" 
    value="40" color="accent"></mat-progress-bar>


Output:

 



Last Updated : 17 Feb, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads