# Progress bar

**Progress bars** notify users that an app needs more time to process a user action, and if possible tell how much time (approximately) it will take.

## Usage

Progress bars inform users about the status of ongoing processes, such as loading an app, documents or data, submitting a form, saving data and more.

### When to use

Use a progress bar for any action that takes longer than about **one second**. Anything shorter than that will act distracting to users.

### Best practices

- An application should provide visual feedback for any extended waiting/loading period.
- Progress bars shall be used for non-blocking waiting/loading actions.

## Design

A Progress bar consists of the following elements:

![Progress bar](<../images/progress-bar.png>)

> 1. Label (optional), 2. Progress, 3. Track, 4. Value (optional)

Besides the default size, there is also a small variant available.

![Progressbar variations](<../images/progress-bar-usage-variations.png>)

> 1. Default, 2. Small

## Code

### Usage

```
import { SiProgressbarComponent } from '@siemens/element-ng/progressbar';

@Component({
  imports: [SiProgressbarComponent, ...]
})
```

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { Component } from '@angular/core';
import { SiProgressbarComponent } from '@siemens/element-ng/progressbar';

@Component({
  selector: 'app-sample',
  imports: [SiProgressbarComponent],
  templateUrl: './si-progressbar-dynamic.html',
  host: { class: 'p-5' }
})
export class SampleComponent {
  maxProgress = 200;
  dynamic = 42;

  random(): void {
    this.dynamic = Math.floor(Math.random() * 100 + 1);
  }
}
```

Template:

```html
<div class="mb-8">
  <small><em>Graphical progress indication</em></small>
  <si-progressbar
    heading="Uploading asset information"
    [progress]="dynamic + ' %'"
    [max]="maxProgress"
    [value]="dynamic"
  />
</div>
<div class="mb-8">
  <small><em>Small graphical progress indication without percentage and heading</em></small>
  <si-progressbar height="small" [value]="dynamic"
    ><b>{{ dynamic }}%</b></si-progressbar
  >
</div>
<button type="button" class="btn btn-primary" (click)="random()">Randomize</button>
```

### [SiProgressbarComponent](<https://github.com/siemens/element/blob/main/projects/element-ng/progressbar/si-progressbar.component.ts#L14-L60>)

**Kind:** component

**Selector:** `si-progressbar`

```
import { SiProgressbarComponent } from '@siemens/element-ng/progressbar';
```

```
component SiProgressbarComponent
```

#### Input Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [ariaLabel](<https://github.com/siemens/element/blob/main/projects/element-ng/progressbar/si-progressbar.component.ts#L23-L23>) | `TranslatableString` | `` $localize`:@@SI_PROGRESSBAR.LABEL:Progress` `` | Needed for a11y |
| [heading](<https://github.com/siemens/element/blob/main/projects/element-ng/progressbar/si-progressbar.component.ts#L42-L42>) | `TranslatableString \| undefined` |  | Heading to display on top of progress bar. |
| [height](<https://github.com/siemens/element/blob/main/projects/element-ng/progressbar/si-progressbar.component.ts#L55-L55>) | `ProgressbarHeight` | `'normal'` | Height for progress bar. |
| [max](<https://github.com/siemens/element/blob/main/projects/element-ng/progressbar/si-progressbar.component.ts#L30-L30>) | `number` | `100` | Max value for progressbar |
| [progress](<https://github.com/siemens/element/blob/main/projects/element-ng/progressbar/si-progressbar.component.ts#L48-L48>) | `string \| undefined` |  | Optional progress text to be shown on top right (in LTR). It can be percentage value or a progress status. E.g `50 %` or `Downloading 2/8`. |
| [value](<https://github.com/siemens/element/blob/main/projects/element-ng/progressbar/si-progressbar.component.ts#L37-L37>) | `number \| undefined` | `0` | Current value |

### Types Documentation

### [ProgressbarHeight](<https://github.com/siemens/element/blob/main/projects/element-ng/progressbar/si-progressbar.component.ts#L62-L62>)

**Kind:** type alias

```
import type { ProgressbarHeight } from '@siemens/element-ng/progressbar';
```

```
type ProgressbarHeight = 'small' | 'normal'
```

### [TranslatableString](<https://github.com/siemens/element/blob/main/projects/element-translate-ng/translate-types/global.types.ts#L18-L18>)

**Kind:** type alias

```
import type { TranslatableString } from '@siemens/element-translate-ng/translate-types';
```

Represents a translatable string. This can either be a translation key, e.g. `ACTIONS.EDIT` that will be automatically translated when displayed on the UI or a pre-translated string, e.g. `Edit`. Equivalent to a normal string in usage and functionality.

```
type TranslatableString = string & Translatable
```
