progress

Displays an indicator showing the completion progress of a task.

PreviousNext
import { afterNextRender, ChangeDetectionStrategy, Component, signal } from '@angular/core';

import { ZardProgressComponent } from '@/shared/components/progress/progress.component';

@Component({
  selector: 'z-demo-progress-preview',
  imports: [ZardProgressComponent],
  template: `
    <z-progress class="w-60" [value]="value()" />
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ZardDemoProgressPreviewComponent {
  protected readonly value = signal(13);

  constructor() {
    afterNextRender(() => {
      setTimeout(() => this.value.set(66), 500);
    });
  }
}

Installation

Copy
npx zard-cli@latest add progress

Usage

import { ZardProgressComponent } from '@/shared/components/progress/progress.component';
Copy
<z-progress [value]="60"></z-progress>
Copy

Examples

with label and value

Compose z-field-label above z-progress to render a label and the numeric value together.
Upload progress66%
import { ChangeDetectionStrategy, Component } from '@angular/core';

import { ZardFieldImports } from '@/shared/components/field/field.imports';
import { ZardProgressComponent } from '@/shared/components/progress/progress.component';

@Component({
  selector: 'z-demo-progress-with-label-and-value',
  imports: [ZardProgressComponent, ...ZardFieldImports],
  template: `
    <z-field class="w-full min-w-sm">
      <z-field-label for="progress-upload">
        <span>Upload progress</span>
        <span class="ms-auto">66%</span>
      </z-field-label>
      <z-progress id="progress-upload" [value]="66" />
    </z-field>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ZardDemoProgressWithLabelAndValueComponent {}

controlled

Bind [value] on z-progress to a z-slider's (zSlideIndexChange) output for a controlled progress bar.
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';

import { ZardProgressComponent } from '@/shared/components/progress/progress.component';
import { ZardSliderComponent } from '@/shared/components/slider/slider.component';

@Component({
  selector: 'z-demo-progress-controlled',
  imports: [ZardProgressComponent, ZardSliderComponent],
  template: `
    <div class="flex w-full min-w-sm flex-col gap-4">
      <z-progress [value]="value()[0]" />
      <z-slider [zValue]="value()" zMin="0" zMax="100" zStep="1" (zSlideIndexChange)="value.set($event)" />
    </div>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ZardDemoProgressControlledComponent {
  protected readonly value = signal([50]);
}

rtl

To enable RTL support in zard/ui, see the RTL configuration guide.
تقدم الرفع66%
// You will notice this example is rendered inside a wrapper that sets the dir and data-lang attributes, and
// reads its text from a translations helper. This is because this site is not RTL by default.
// In your application you won't need either: set dir="rtl" on <html> (or use the CDK Dir directive on a subtree)
// and write the text of your own language. See the RTL guide: https://zardui.com/docs/rtl

import { ChangeDetectionStrategy, Component } from '@angular/core';

import { ZardFieldImports } from '@/shared/components/field/field.imports';
import { ZardProgressComponent } from '@/shared/components/progress/progress.component';
import { injectRtlTranslation, type ZardRtlTranslations } from '@/shared/demo-utils/rtl-translation';

const translations: ZardRtlTranslations<{ label: string }> = {
  en: {
    dir: 'ltr',
    values: {
      label: 'Upload progress',
    },
  },
  ar: {
    dir: 'rtl',
    values: {
      label: 'تقدم الرفع',
    },
  },
  he: {
    dir: 'rtl',
    values: {
      label: 'התקדמות ההעלאה',
    },
  },
};

@Component({
  selector: 'z-demo-progress-rtl',
  imports: [ZardProgressComponent, ...ZardFieldImports],
  template: `
    <z-field class="w-full min-w-sm">
      <z-field-label for="progress-upload-rtl">
        <span>{{ i18n.t().label }}</span>
        <span class="ms-auto">66%</span>
      </z-field-label>
      <z-progress id="progress-upload-rtl" [value]="66" />
    </z-field>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ZardDemoProgressRtlComponent {
  protected readonly i18n = injectRtlTranslation(translations);
}

API Reference

z-progressComponent

Displays an indicator showing the completion progress of a task.

PropertyDescriptionTypeDefault
[value] Current progress value between 0 and 100. Values outside this range are clamped. number 0
[class] Override or extend the default classes (height, color, etc). ClassValue -
github iconwhatsapp icondiscord iconX icon

Made with ❤ in Brazil. Open source and available on GitHub .