# Tour

**Tour** provides a guided walkthrough of an application's key features and functions, helping users understand and navigate the interface effectively.

## Usage

Use the **tour** to guide users through a series of steps or features within an application, offering contextual information and instructions to enhance the user experience.

![Tour](<../images/tour.png>)

### When to use

- To introduce new users to the application and its primary features.
- To guide users through a new workflow.
- To highlight significant updates or changes in the interface.
- To provide in-app training or onboarding for users.

### Best practices

- Keep tours between 3 and 15 steps.
- Each step should have a clear and concise description.
- Focus on how the feature or function can benefit the user.
- Organize the tour steps in a logical sequence that mirrors the user’s workflow.
- Avoid overwhelming users with too much information at once.

## Design

### Elements

![Tour elements](<../images/tour-elements.png>)

> 1. Step number, 2. Title, 3. Description, 4. Actions, 5. Arrow (optional), 6. Close button

Tours can be automatically launched for new users during their first login to guide them through the UI. Automatic tours are best for first-time use only.

Users can access guided tours anytime from the Help menu in the [application header](<https://element.siemens.io/components/layout-navigation/application-header/>).

If more than one tour is offered, they can be organized within the Help menu into categories such as "Getting started", "Advanced features" or "New features" for easy navigation.

![Tour trigger](<../images/tour-trigger.png>)

### Tour beginning and end

The first step gives a brief overview of what to expect from the tour, with the option to skip it. The last step concludes the tour, summarizing key points and optionally offering additional resources.

![Tour steps](<../images/tour-steps.png>)

### Placement

The tour popover is automatically positioned above, below, to the left, or to the right of an element based on its screen position. The arrow can be placed along any edge to ensure optimal positioning.

## Code

### Usage

```
import { SiTourService } from '@siemens/element-ng/tour';

@NgModule({
  imports: [SiTourService, ...]
})
```

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { AfterViewInit, Component, inject, OnDestroy } from '@angular/core';
import { RouterLink } from '@angular/router';
import { SiAccordionComponent, SiCollapsiblePanelComponent } from '@siemens/element-ng/accordion';
import {
  App,
  SiApplicationHeaderComponent,
  SiHeaderAccountItemComponent,
  SiHeaderActionItemComponent,
  SiHeaderActionsDirective,
  SiHeaderBrandDirective,
  SiHeaderLogoDirective,
  SiLaunchpadFactoryComponent
} from '@siemens/element-ng/application-header';
import { BreadcrumbItem, SiBreadcrumbComponent } from '@siemens/element-ng/breadcrumb';
import {
  SiHeaderDropdownComponent,
  SiHeaderDropdownItemComponent,
  SiHeaderDropdownTriggerDirective
} from '@siemens/element-ng/header-dropdown';
import { NavbarVerticalItem, SiNavbarVerticalComponent } from '@siemens/element-ng/navbar-vertical';
import { SiSearchBarComponent } from '@siemens/element-ng/search-bar';
import { SiSidePanelComponent, SiSidePanelContentComponent } from '@siemens/element-ng/side-panel';
import { SiStatusBarComponent, StatusBarItem } from '@siemens/element-ng/status-bar';
import { SiTourService, TourStep } from '@siemens/element-ng/tour';

@Component({
  selector: 'app-sample',
  imports: [
    SiAccordionComponent,
    SiBreadcrumbComponent,
    SiCollapsiblePanelComponent,
    SiNavbarVerticalComponent,
    SiSearchBarComponent,
    SiSidePanelComponent,
    SiSidePanelContentComponent,
    SiStatusBarComponent,
    RouterLink,
    SiApplicationHeaderComponent,
    SiHeaderAccountItemComponent,
    SiHeaderDropdownTriggerDirective,
    SiHeaderDropdownComponent,
    SiHeaderActionItemComponent,
    SiHeaderActionsDirective,
    SiHeaderBrandDirective,
    SiHeaderDropdownItemComponent,
    SiLaunchpadFactoryComponent,
    SiHeaderLogoDirective
  ],
  templateUrl: './si-tour.html'
})
export class SampleComponent implements AfterViewInit, OnDestroy {
  breadcrumbItems: BreadcrumbItem[] = [
    { title: 'Root', link: 'root' },
    { title: 'Level 1', link: ['root', 'level1'] },
    { title: 'Level 2', link: ['root', 'level1', 'level2'] }
  ];

  statusItems: StatusBarItem[] = [
    { title: 'Security', status: 'danger', value: 4 },
    { title: 'Update', status: 'warning', value: 14 },
    { title: 'Information', status: 'info', value: 37 }
  ];

  appItems: App[] = [
    { name: 'Account', iconClass: 'element-account', href: './account-app' },
    { name: 'Asset', iconClass: 'element-floor', href: './asset-app' },
    {
      name: 'Operations',
      iconClass: 'element-plant',
      href: './operations-app',
      active: true
    },
    { name: 'App Portal', iconClass: 'element-security', href: './app-portal' },
    {
      name: 'App Service',
      iconClass: 'element-automation-station',
      href: './app-service'
    },
    { name: 'App Tool', iconClass: 'element-global', href: './app-tool' }
  ];

  menuItems: NavbarVerticalItem[] = [
    {
      type: 'group',
      label: 'Home',
      icon: 'element-home',
      children: [
        {
          type: 'router-link',
          label: 'Sub Item',
          routerLink: 'subItem',
          badge: 4,
          badgeColor: 'warning'
        },
        {
          type: 'router-link',
          label: 'Sub Item 2',
          routerLink: 'subItem2'
        },
        {
          type: 'router-link',
          label: 'Sub Item 3',
          routerLink: 'subItem3'
        }
      ]
    },
    {
      type: 'group',
      label: 'Documentation',
      icon: 'element-document',
      children: [
        {
          type: 'router-link',
          label: 'Sub Item 4',
          routerLink: 'subItem4'
        },
        {
          type: 'router-link',
          label: 'Sub Item 5',
          routerLink: 'subItem5'
        },
        {
          type: 'router-link',
          label: 'Sub Item 6',
          routerLink: 'subItem6'
        }
      ]
    },
    {
      type: 'router-link',
      label: 'Energy',
      icon: 'element-trend',
      routerLink: 'energy'
    },
    {
      type: 'router-link',
      label: 'Test Coverage',
      icon: 'element-diagnostic',
      routerLink: 'coverage'
    }
  ];

  startTour = (): void => this.tourService.start();

  private tourService = inject(SiTourService);

  constructor() {
    const steps = this.getSteps();
    this.tourService.addSteps(steps);
  }

  ngAfterViewInit(): void {
    this.tourService.start();
  }

  ngOnDestroy(): void {
    this.tourService.complete();
  }

  private timeout = async (ms?: number): Promise<void> =>
    new Promise(resolve => setTimeout(resolve, ms));

  private getSteps(): TourStep[] {
    return [
      {
        attachTo: {
          element: 'si-status-bar'
        },
        id: 'status-bar',
        title: 'Status bar',
        text: 'Information about events or actions that requires user attention.'
      },
      {
        attachTo: {
          element: '.main-content h2'
        },
        id: 'page-title',
        title: 'Page title',
        text: 'Title describing the page content.'
      },
      {
        attachTo: {
          element: '.mb-6 si-search-bar input'
        },
        id: 'search-bar',
        title: 'Search bar',
        text: 'Search bar to search information in the page.'
      },
      {
        attachTo: {
          element: 'si-navbar-vertical nav'
        },
        id: 'navbar',
        title: 'Vertical navbar',
        text: 'Hierarchical global navigation displaying navigation options.',
        beforeShowPromise: () => this.timeout(400)
      },
      {
        attachTo: {
          element: 'si-side-panel-content'
        },
        id: 'side-panel',
        title: 'Side panel',
        text: 'The side panel is used to display additional content or functionality that is related to the main content of a page.'
      },
      {
        attachTo: {
          element: 'si-header-dropdown.show'
        },
        id: 'help-menu',
        title: 'Help menu',
        text: 'The help menu provides help in case you need it.',
        beforeShowPromise: () => {
          document.querySelector<HTMLButtonElement>('si-header-actions .element-help')?.click();
          return this.timeout(100);
        },
        beforeNextPromise: () => {
          // click again to hide menu
          const menu = document.querySelector('si-header-dropdown.show');
          if (menu) {
            document.querySelector<HTMLButtonElement>('si-header-actions .element-help')?.click();
            return this.timeout(20);
          }
          return Promise.resolve();
        }
      },
      {
        id: 'finish',
        title: 'Tour completed',
        text: 'The guided tour is now complete. Thank you.',
        imgSrc: 'assets/images/tour-example.png',
        imgAlt: 'A hand holding a phone displaying a building, with location and fire symbols.',
        imgClass: 'background-0'
      }
    ];
  }
}
```

Template:

```html
<div class="has-navbar-fixed-top si-layout-fixed-height h-100">
  <si-application-header [launchpad]="launchpad">
    <si-header-brand>
      <a siHeaderLogo routerLink="/" class="d-none d-md-flex"></a>
      <h1 class="application-name">Application name</h1>
    </si-header-brand>

    <si-header-actions>
      <button
        si-header-action-item
        type="button"
        icon="element-help"
        [siHeaderDropdownTriggerFor]="help"
      >
        Help
      </button>
      <ng-template #help>
        <si-header-dropdown>
          <button si-header-dropdown-item type="button">Help</button>
          <button si-header-dropdown-item type="button">Tour</button>
          <div class="dropdown-divider"></div>
          <button si-header-dropdown-item type="button">About</button>
          <a si-header-dropdown-item href="http://www.siemens.com/corporate-information"
            >Corporate Information</a
          >
        </si-header-dropdown>
      </ng-template>

      <button
        si-header-account-item
        type="button"
        name="Jane Smith"
        [siHeaderDropdownTriggerFor]="account"
      >
      </button>
      <ng-template #account>
        <si-header-dropdown>
          <div class="mx-5">
            <div class="si-h5">Jane Smith</div>
            <div>jane.smith&#64;example.org</div>
            <div class="d-flex align-items-center text-secondary mt-2">ExampleOrg</div>
          </div>
        </si-header-dropdown>
      </ng-template>
    </si-header-actions>
  </si-application-header>
  <ng-template #launchpad>
    <si-launchpad-factory [apps]="appItems" />
  </ng-template>
  <si-navbar-vertical
    navbarCollapseButtonText="collapse"
    navbarExpandButtonText="expand"
    [items]="menuItems"
  >
    <si-side-panel mode="scroll" [collapsible]="true">
      <div class="si-layout-main-padding si-layout-fixed-height">
        <si-status-bar class="si-layout-status si-layout-top-element" [items]="statusItems" />
        <si-breadcrumb class="si-layout-breadcrumb" [items]="breadcrumbItems" />
        <div class="si-layout-header">
          <h2 class="si-layout-title">Title describing what page content to expect</h2>
          <p class="si-layout-subtitle">Lorem ipsum dolor sit amet, ...</p>
          <div class="si-layout-actions row">
            <div class="col-auto">
              <button type="button" class="btn btn-secondary">Print</button>
            </div>
            <div class="col-auto">
              <button type="button" class="btn btn-primary" (click)="startTour()">Tour</button>
            </div>
          </div>
        </div>

        <div class="mb-6">
          <div class="row gy-6">
            <si-search-bar placeholder="Search" class="col-12 col-md" [showIcon]="true" />
            <div class="col-auto">
              <button type="button" class="btn btn-secondary">Toolbar item</button>
            </div>
          </div>
        </div>

        <div class="border rounded-2 si-layout-fixed-height p-4 mb-5"
          >Placeholder for the content of the page, using the fixed height layout.</div
        >
      </div>

      <si-side-panel-content heading="Cooling coil" [searchable]="true">
        <si-accordion [fullHeight]="true">
          <si-collapsible-panel
            heading="Properties"
            icon="element-settings"
            contentCssClasses="p-6"
          >
            And here we have some content
          </si-collapsible-panel>
          <si-collapsible-panel heading="Documents" icon="element-document" contentCssClasses="p-6">
            And this is the content
          </si-collapsible-panel>
          <si-collapsible-panel heading="Graphics" icon="element-image" contentCssClasses="p-6">
            Nothing to see here
          </si-collapsible-panel>
        </si-accordion>
      </si-side-panel-content>
    </si-side-panel>
  </si-navbar-vertical>
</div>
<div class="visually-hidden" id="status-bar-label">Status bar</div>
<div class="visually-hidden" id="page-title-label">Page title</div>
<div class="visually-hidden" id="finish-label">Thank you</div>
```

### [SiTourService](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.service.ts#L23-L336>)

**Kind:** class

**Provided in:** `root`

```
import { SiTourService } from '@siemens/element-ng/tour';
```

```
undecorated_class SiTourService
```

#### Attributes and Methods

##### addSteps

[Source for addSteps](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.service.ts#L72-L74>)

Add steps to the tour

```
addSteps(steps: TourStep[]): void
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [steps](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.service.ts#L72-L72>) | `TourStep[]` |  |  |

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

##### clearSteps

[Source for clearSteps](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.service.ts#L79-L82>)

Clear all steps

```
clearSteps(): void
```

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

##### complete

[Source for complete](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.service.ts#L94-L96>)

Finish the tour

```
complete(): void
```

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

##### onTourCancel

[Source for onTourCancel](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.service.ts#L60-L60>)

**Modifiers:** readonly

**Type:** `Subject<void>`

**Default:** `new Subject<void>()`

Event triggered after the tour is cancelled, either through skip button or closing the tour dialog.

##### onTourComplete

[Source for onTourComplete](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.service.ts#L55-L55>)

**Modifiers:** readonly

**Type:** `Subject<void>`

**Default:** `new Subject<void>()`

Event triggered after the tour is completed.

##### setOptions

[Source for setOptions](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.service.ts#L65-L67>)

Sets options for the whole tour.

```
setOptions(options: TourOptions): void
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [options](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.service.ts#L65-L65>) | `TourOptions` |  |  |

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

##### start

[Source for start](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.service.ts#L87-L89>)

Start the tour

```
start(): void
```

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

### Types Documentation

### [TourOptions](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L53-L56>)

**Kind:** interface

```
import type { TourOptions } from '@siemens/element-ng/tour';
```

Options for tour

```
interface TourOptions
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [defaultStepOptions](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L55-L55>) (optional) | `TourStepCommonOptions` | Default options applied to all tour steps. |

### [TourStep](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L28-L50>)

**Kind:** interface

```
import type { TourStep } from '@siemens/element-ng/tour';
```

Options for each tour step.

```
interface TourStep extends TourStepCommonOptions
```

#### Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [attachTo](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L47-L49>) (optional) | `{ element: string \| HTMLElement \| (() => string \| HTMLElement); }` |  | The element, the step should be attached to on the page. |
| [beforeNextPromise](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L24-L24>) (optional, inherited) | `(() => Promise<any>)` |  | A function that returns a promise. When the promise resolves, the next step will be shown. This can be used to 'clean up' action from `beforeShowPromise`.<br><br>Inherited from [TourStepCommonOptions](<index.html#t:TourStepCommonOptions>) |
| [beforeShowPromise](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L18-L18>) (optional, inherited) | `(() => Promise<any>)` |  | A function that returns a promise. When the promise resolves, the step will be shown. E.g. use this to open dialogs, etc.<br><br>Inherited from [TourStepCommonOptions](<index.html#t:TourStepCommonOptions>) |
| [id](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L30-L30>) (optional) | `string` |  | Unique id for the step. Exposed in DOM as `data-step-id` |
| [imgAlt](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L38-L38>) (optional) | `TranslatableString` |  | Alt text for a provided image. |
| [imgClass](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L40-L40>) (optional) | `string` |  | CSS class applied to the image. |
| [imgObjectFit](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L45-L45>) (optional) | `"fill" \| "contain" \| "cover" \| "none" \| "scale-down"` | `'scale-down'` | Sets the image [object-fit](<https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit>) CSS property. |
| [imgSrc](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L36-L36>) (optional) | `string` |  | Optional image source to display. |
| [scrollTo](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L10-L10>) (optional, inherited) | `boolean \| ScrollIntoViewOptions` |  | Whether Scroll the element into view.<br><br>Inherited from [TourStepCommonOptions](<index.html#t:TourStepCommonOptions>) |
| [scrollToHandler](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L12-L12>) (optional, inherited) | `((element: HTMLElement) => void)` |  | Custom handler to perform scrolling.<br><br>Inherited from [TourStepCommonOptions](<index.html#t:TourStepCommonOptions>) |
| [text](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L34-L34>) (optional) | `TranslatableString` |  | Body text of the modal. |
| [title](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L32-L32>) | `TranslatableString` |  | Title to be displayed on the modal. |

### [TourStepCommonOptions](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L8-L25>)

**Kind:** interface

```
import type { TourStepCommonOptions } from '@siemens/element-ng/tour';
```

Common options for tour step and as default for tour step

```
interface TourStepCommonOptions
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [beforeNextPromise](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L24-L24>) (optional) | `(() => Promise<any>)` | A function that returns a promise. When the promise resolves, the next step will be shown. This can be used to 'clean up' action from `beforeShowPromise`. |
| [beforeShowPromise](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L18-L18>) (optional) | `(() => Promise<any>)` | A function that returns a promise. When the promise resolves, the step will be shown. E.g. use this to open dialogs, etc. |
| [scrollTo](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L10-L10>) (optional) | `boolean \| ScrollIntoViewOptions` | Whether Scroll the element into view. |
| [scrollToHandler](<https://github.com/siemens/element/blob/main/projects/element-ng/tour/si-tour.model.ts#L12-L12>) (optional) | `((element: HTMLElement) => void)` | Custom handler to perform scrolling. |

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