# Status bar

The **status bar** is used to convey crucial and system-wide information to users. Different severity symbols help users to quickly evaluate and recognize the current system status, providing the required information to take appropriate actions.

## Usage

![Statusbar](<../images/statusbar.png>)

The **status bar** component informs a user about events or actions that requires their attention and provides an easily accessible and summarized overview of all ongoing events.

It is located just beneath the main horizontal navigation and is always visible on all pages. If needed, each item can be a link to a page with detailed information, containing all necessary means to identify and further analyze a problem or specific status.

The status bar is not part of the scrollable content area, it stays at the same position at all times.

### When to use

- Use it when some important status information has to be visible at all times, regardless of how deep the user navigated within an application.
- Use it to provide quick access to critical information that users need to be aware of at all times.
- Use it in combination with the [circle status](<https://element.siemens.io/components/status-notifications/circle-status/>) component.

### Best practices

- Only include the most relevant status information.
- Do not include more than `10` status categories.

## Design

### Elements

![Status bar elements](<../images/status-bar-elements.png>)

> 1. Container, 2. Status item active, 3. Status item inactive, 4. Mute button (optional)

Status items provide users with a quick way to see how many active events are associated with each event category.

![Status bar item](<../images/status-bar-item.png>)

> 1. Event severity indicator, 2. Event category name, 3. Event counter

### Variants

If required, the status bar can be configured in a *reduced height*/*compact mode*.

![Status bar sizes](<../images/status-bar-sizes.png>)

### Responsive behavior

The responsive behavior of the component ensures access to all information regardless of the available screen size.

- If there are no active events, the status bar will display the message `All ok`.
- If there are more active items than can fit within the designated space, items will be moved to a collapsed menu and a summary indicator will be shown to indicate that more items are available.

![Status bar responsive](<../images/status-bar-responsive.png>)

### Pulsating state (optional)

To steer a user's attention to new and unhandled events in the status bar, the status items support a *blinking* feature, which fades the background opacity.

![Status bar blinking](<../images/status-bar-blink.png>)

## Code

Component for showing various status indicators and should be used below `si-application-header`.

Items in the status bar are clickable and will emit details of the item when clicked.

### Usage

```
import { SiStatusBarComponent } from '@siemens/element-ng/status-bar';

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

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { Component, DestroyRef, inject, OnInit } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormsModule } from '@angular/forms';
import { BlinkService } from '@siemens/element-ng/common';
import { SiFormItemComponent } from '@siemens/element-ng/form';
import { SiStatusBarComponent, StatusBarItem } from '@siemens/element-ng/status-bar';
import { LOG_EVENT } from '@siemens/live-preview';
import { timer } from 'rxjs';

@Component({
  selector: 'app-sample',
  imports: [SiFormItemComponent, SiStatusBarComponent, FormsModule],
  templateUrl: './si-status-bar.html'
})
export class SampleComponent implements OnInit {
  private readonly logEvent = inject(LOG_EVENT);
  private readonly blink = inject(BlinkService);
  private readonly destroyRef = inject(DestroyRef);

  muteButton? = false;
  compact = false;
  showMute = true;
  customContent = false;

  readonly statusItems: StatusBarItem[] = [
    { title: 'Emergency', status: 'critical', value: 4, action: item => this.logEvent(item) },
    { title: 'Life safety', status: 'danger', value: 0, action: item => this.logEvent(item) },
    { title: 'Security', status: 'danger', value: 0 },
    { title: 'Supervisory', status: 'danger', value: 0 },
    { title: 'Trouble', status: 'warning', value: 42, action: item => this.logEvent(item) },
    { title: 'Caution', status: 'caution', value: 200, action: item => this.logEvent(item) },
    { title: 'Nasty long text', status: 'info', value: 1, action: item => this.logEvent(item) },
    { title: 'Not clickable', status: 'info', value: 37 }
  ];

  shouldBlink = !navigator.webdriver;

  ngOnInit(): void {
    // disable updating content in e2e tests
    if (!navigator.webdriver) {
      const origValues = this.statusItems.map(item => item.value);

      timer(5000, 7000)
        .pipe(takeUntilDestroyed(this.destroyRef))
        .subscribe(() => {
          this.statusItems[3].value = this.statusItems[3].value ? 0 : 5;
        });

      timer(15000, 17000)
        .pipe(takeUntilDestroyed(this.destroyRef))
        .subscribe(() => {
          if (this.statusItems[0].value) {
            this.statusItems.forEach(item => (item.value = 0));
          } else {
            this.statusItems.forEach((item, i) => (item.value = origValues[i]));
          }
        });
    }
  }

  pause(): void {
    this.blink.pause();
  }

  resume(): void {
    this.blink.resume();
  }
}
```

Template:

```html
<div class="p-5">
  <si-status-bar
    class="si-layout-status"
    [items]="statusItems"
    [compact]="compact"
    [blink]="shouldBlink"
    [muteButton]="showMute ? muteButton : undefined"
    (muteToggle)="muteButton = !muteButton"
  >
    @if (customContent) {
      <button type="button" class="btn btn-secondary mx-2 my-1">Add</button>
    }
  </si-status-bar>

  <p>Here goes the content</p>
</div>

<div class="card m-5 e2e-ignore">
  <div class="card-header">Control panel</div>
  <div class="card-body">
    <div class="row">
      <div class="col-sm-3">
        <si-form-item label="Show mute button">
          <input type="checkbox" class="form-check-input" [(ngModel)]="showMute" />
        </si-form-item>
      </div>
      <div class="col-sm-3">
        <si-form-item label="Compact mode">
          <input type="checkbox" class="form-check-input" [(ngModel)]="compact" />
        </si-form-item>
      </div>
      <div class="col-sm-3">
        <si-form-item label="Show custom content">
          <input type="checkbox" class="form-check-input" [(ngModel)]="customContent" />
        </si-form-item>
      </div>
    </div>
    <div class="mt-3">
      <button type="button" class="btn btn-secondary me-4" (click)="pause()">Pause blinking</button>
      <button type="button" class="btn btn-secondary me-4" (click)="resume()"
        >Resume blinking</button
      >
    </div>
  </div>
</div>
```

### [SiStatusBarComponent](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar.component.ts#L68-L360>)

**Kind:** component

**Selector:** `si-status-bar`

```
import { SiStatusBarComponent } from '@siemens/element-ng/status-bar';
```

The status bar is the main component within an application to inform users at all times about important status information.

```
component SiStatusBarComponent implements OnDestroy, OnChanges
```

#### Input Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [allOkText](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar.component.ts#L111-L111>) | `TranslatableString` | `` $localize`:@@SI_STATUS_BAR.ALL_OK:All OK` `` | Text/translation key for "All OK" status in mobile |
| [blink](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar.component.ts#L89-L89>) | `boolean` | `false` | When true, items with a value have a blinking background |
| [blinkPulse](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar.component.ts#L121-L121>) | `Observable<boolean> \| undefined` |  | blink pulse generator for synchronized blinking with other components |
| [compact](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar.component.ts#L117-L117>) | `boolean` | `false` | compact mode |
| [items](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar.component.ts#L83-L83>) (required) | `StatusBarItem[]` |  | Array of status bar items. |
| [muteButton](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar.component.ts#L93-L93>) | `boolean \| undefined` |  | State of the mute button. Set to `undefined` for no button. |
| [muteButtonText](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar.component.ts#L102-L102>) | `TranslatableString` | `` $localize`:@@SI_STATUS_BAR.MUTE:Mute/unmute` `` | Text/translation key on mute button for screen reader |
| [toggleButtonText](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar.component.ts#L131-L131>) | `TranslatableString` | `` $localize`:@@SI_STATUS_BAR.TOGGLE:Toggle` `` | Text for the toggle button that expands/collapses the status bar. Required for a11y. The expanded/collapsed state is communicated separately via `aria-expanded`. |

#### Output Properties

| Name | Type | Description |
| --- | --- | --- |
| [muteToggle](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar.component.ts#L136-L136>) | `void` | Emitted when the mute toggle button is clicked |

### Types Documentation

### [StatusBarItem](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar-item/si-status-bar-item.model.ts#L7-L38>)

**Kind:** interface

```
import type { StatusBarItem } from '@siemens/element-ng/status-bar';
```

```
interface StatusBarItem
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [action](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar-item/si-status-bar-item.model.ts#L37-L37>) (optional) | `((item: StatusBarItem) => void)` | Function to call when the item is clicked. |
| [blink](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar-item/si-status-bar-item.model.ts#L33-L33>) (optional) | `boolean` | When blinking is enabled, allows to explicitly disable blinking. `undefined` and `true` mean blink. |
| [color](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar-item/si-status-bar-item.model.ts#L28-L28>) (optional, deprecated) | `string` | Custom color as CSS value if `status` is not specified<br><br>Deprecated: use the semantic `status` input instead. |
| [status](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar-item/si-status-bar-item.model.ts#L19-L19>) (optional) | `ExtendedStatusType` | Status of the item. If not specified, specify `color` |
| [title](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar-item/si-status-bar-item.model.ts#L15-L15>) | `string` | A descriptive title |
| [value](<https://github.com/siemens/element/blob/main/projects/element-ng/status-bar/si-status-bar-item/si-status-bar-item.model.ts#L11-L11>) | `string \| number` | The value to show. 0 or '' means greyed out |

### [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
```

### [ExtendedStatusType](<https://github.com/siemens/element/blob/main/projects/element-ng/common/models/status-type.model.ts#L8-L8>)

**Kind:** type alias

```
import type { ExtendedStatusType } from '@siemens/element-ng/common';
```

```
type ExtendedStatusType = StatusType | 'unknown'
```

### [StatusType](<https://github.com/siemens/element/blob/main/projects/element-ng/common/models/status-type.model.ts#L7-L7>)

**Kind:** type alias

```
import type { StatusType } from '@siemens/element-ng/common';
```

```
type StatusType = 'success' | 'info' | 'warning' | 'danger' | 'caution' | 'critical'
```
