# Help button

The **help button** provides immediate, contextual assistance via a [popover](<https://element.siemens.io/components/status-notifications/popover/>).

## Usage

It is designed to help users understand specific actions or features on the current page without navigating away. The button uses the `element-help` icon and is typically placed near form labels or interactive elements that require clarification.

![Help button](<../images/help-button.png>)

### When to use

- When users may need clarification about a specific field, feature, or action.
- In forms, dashboards, or complex workflows.

### Best practices

- Keep content short and focused on the immediate context.
- Include links to more detailed information only when necessary.
- Position the help button to the right of the element it supports (or left for RTL languages).
- Avoid overusing help buttons across a page. When more complex or detailed information is required, refer to the other [help patterns](<https://element.siemens.io/patterns/help/>).

## Design

### Elements

![Help button elements](<../images/help-button-elements.png>)

> 1. Help button, 2. Popover

### States

![Help button states](<../images/help-button-states.png>)

## Code

### Usage

```
import { SiHelpButtonComponent } from '@siemens/element-ng/help-button';

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

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { Component, inject } from '@angular/core';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { SiFormItemComponent } from '@siemens/element-ng/form';
import { SiHelpButtonComponent } from '@siemens/element-ng/help-button';
import { LOG_EVENT } from '@siemens/live-preview';

@Component({
  selector: 'app-sample',
  imports: [SiHelpButtonComponent, SiFormItemComponent, ReactiveFormsModule],
  templateUrl: './si-help-button.html',
  host: {
    class: 'p-5'
  }
})
export class SampleComponent {
  private log = inject(LOG_EVENT);
  readonly disabledHelp = new FormControl(false);

  solve(): void {
    this.log('Solution');
  }
}
```

Template:

```html
<div class="d-flex gap-2 pt-1 pb-3">
  <span class="text-secondary si-body">Repo Storage</span>
  <button
    si-help-button
    type="button"
    siHelpTitle="Repo Storage calculation"
    [siHelpContent]="storageHelp"
    [disabled]="disabledHelp.value"
  >
    <!-- This text is only visible to screen reader. Provide a meaningful text, not only "help" -->
    How to calculate repo storage
  </button>
</div>
<span class="pt-1 si-h5">9.99 MB</span>

<ng-template #storageHelp>
  The Repo Storage is the overall size of the repository plus all LFS objects and pipelines
  artifacts.
</ng-template>

<si-form-item label="Disable help button" class="mt-5">
  <input type="checkbox" class="form-check-input" [formControl]="disabledHelp" />
  <button
    si-help-button
    type="button"
    siHelpTitle="Button triggerring"
    siHelpContent="You can trigger a button by clicking it"
    >How to trigger this button</button
  >
</si-form-item>
```

### [SiHelpButtonComponent](<https://github.com/siemens/element/blob/main/projects/element-ng/help-button/si-help-button.component.ts#L48-L50>)

**Kind:** component

**Selector:** `button[si-help-button]`

```
import { SiHelpButtonComponent } from '@siemens/element-ng/help-button';
```

This component creates a help button that shows contextual help in a popover.

Example:

```html
<button
  type="button"
  si-help-button
  siHelpTitle="Help for problem"
  siHelpContent="Use your imagination to solve this problem."
>
  <!-- This text is only visible to screen reader. Provide a meaningful text, not only "help" -->
  How to solve the problem?
</button>
```

```
component SiHelpButtonComponent
```

#### Input Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [siHelpContent](<https://github.com/siemens/element/blob/main/projects/element-ng/popover/si-popover.directive.ts#L46-L46>) | `TranslatableString \| TemplateRef<unknown> \| undefined` |  | The popover text to be displayed |
| [siHelpContext](<https://github.com/siemens/element/blob/main/projects/element-ng/popover/si-popover.directive.ts#L94-L94>) | `unknown` | `undefined` | The context for the attached template |
| [siHelpPlacement](<https://github.com/siemens/element/blob/main/projects/element-ng/popover/si-popover.directive.ts#L53-L53>) | `"start" \| "end" \| "bottom" \| "auto" \| "top"` | `'auto'` | The placement of the popover. One of 'top', 'start', 'end', 'bottom' |
| [siHelpTitle](<https://github.com/siemens/element/blob/main/projects/element-ng/popover/si-popover.directive.ts#L73-L73>) | `TranslatableString \| undefined` | `undefined` | The title to be displayed on top for the popover |

### Types Documentation

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