ProgressBarProgressBar is a process status indicator.

ProgressBar - 图1

Documentation

Import

  1. import {ProgressBarModule} from 'primeng/progressbar';
  2.  

Getting Started

ProgressBar has two modes; "determinate" and "indeterminate". Former requires a value between 0 and 100 to display the progress.

  1. <p-progressBar [value]="value"></p-progressBar>
  2.  
  1. export class ModelComponent {
  2. value: number = 0;
  3. }
  4.  

Indeterminate has no such a requirement and is simple enabled using mode property.

  1. <p-progressBar mode="indeterminate"></p-progressBar>
  2.  

Properties

NameTypeDefaultDescription
valuenumbernullCurrent value of the progress.
showValuebooleantrueShow or hide progress bar value.
unitstring%Unit sign appended to the value.
modestringdeterminateDefines the mode of the progress, valid values are "determinate" and "indeterminate".

Styling

Following is the list of structural style classes, for theming classes visit theming page.

NameElement
ui-progressbarContainer element.
ui-progressbar-determinateContainer element of a determinate progressbar.
ui-progressbar-indeterminateContainer element of an indeterminate progressbar.
ui-progressbar-valueElement whose width changes according to value.
ui-progressbar-labelLabel element that displays the current value.

Dependencies

None.

Source

View on GitHub

  1. <p-toast [style]="{marginTop: '80px'}"></p-toast>
  2. <h3 class="first">Dynamic</h3>
  3. <p-progressBar [value]="value"></p-progressBar>
  4. <h3>Static</h3>
  5. <p-progressBar [value]="50"></p-progressBar>
  6. <h3>Indeterminate</h3>
  7. <p-progressBar mode="indeterminate" [style]="{'height': '6px'}"></p-progressBar>
  8.  
  1. export class ProgressBarDemo {
  2. value: number = 0;
  3. constructor(private messageService: MessageService) {}
  4. ngOnInit() {
  5. let interval = setInterval(() => {
  6. this.value = this.value + Math.floor(Math.random() * 10) + 1;
  7. if(this.value >= 100) {
  8. this.value = 100;
  9. this.messageService.add({severity: 'info', summary: 'Success', detail: 'Process Completed'});
  10. clearInterval(interval);
  11. }
  12. }, 2000);
  13. }
  14. }
  15.