# Page header

**Page header** defines the top of the main content area. It arranges elements that apply context to the current page.

## Usage

Use it to ensure a cohesive appearance at the start of an entire page. It provides fundamental information users need while navigating the page.

![Page header](<../images/page-header.png>)

### When to use

- To provide users with essential information to help them orient themselves and quickly understand the central topic and content of a page.
- To maintain design consistency across pages, creating a familiar and predictable pattern for users.

### Best practices

- The title should be short and to the point.
- Maximal 1 page header per page.
- Don't use it at the top of smaller containers like cards.
- Customize the toolbar and page actions to suit your specific use case.
- Restrict the number of page actions to 3 to 5.
- Take responsive behavior into consideration. Ensure that all functions work well on all screen sizes.
- Refer to [typography](<https://element.siemens.io/fundamentals/typography/>) and [spacing definitions](<https://element.siemens.io/fundamentals/layouts/spacing/>) for more information.

## Design

### Elements

![Page header elements](<../images/page-header-elements.png>)

1. **Navigation (optional)**: Helps users to orient themselves and efficiently navigate through the application with [links](<https://element.siemens.io/components/buttons-menus/links/>) or breadcrumbs.
2. **Page title:** A clear, concise headline that immediately informs users about the content of the page.
3. **Description/Subtitle (optional):** Provides additional context or details to support the page title.
4. **Toolbar (optional):** Contains tools like search bars, filters, or others that help users interact with the page content.
5. **Page actions (optional):** Specific set of commands or operations that users can perform on the current page.

### Placement

- The vertical space between the page header and top element is `16px`.
- Use the text style `H3 Heading` with a `text-accent` color for the page title below 576px. At 576px and above, use the `H2 Heading` text style.
- If a description or subtitle is needed, the use the text style `Body 2` with a `text-secondary` color. The vertical space between the title and subtitle must be `8px`.
- The vertical space between the *Page Title* and the next element must be `24px`.

Page header must always be left aligned in relation to the rest of the content in the screen.

![Page header placement](<../images/page-header-placement.png>)

### Responsive behavior

Adjust the items so that they remain easily accessible and usable. Adapt to various screen sizes by stacking elements while preserving defined spacings. When not all actions can be displayed, prioritize the visibility of the most crucial and frequently used actions.

![Page header responsive](<../images/page-header-responsive.png>)

## Code

### Usage

Element provides CSS layout classes to support building a page header. They are responsive and will automatically reserve space for the vertical-navbar and the side-panel.

- `.si-layout-header` is a container class around the title, subtitle and actions
- `.si-layout-title`, must be `h2`
- `.si-layout-subtitle`, should be `p`
- `.si-layout-actions`, defines the area for buttons or the content action bar

If you have a toolbar, add 16px bottom margin to the content be for example adding the utility class `.mb-6`.

#### .si-layout-actions

When using the `<si-content-action-bar>` to provide page actions, ensure to add the `.si-layout-actions` CSS class directly to the `<si-content-action-bar>` element and the `<si-content-action-bar>` element as a direct child under the element with the `.si-layout-header` class. Otherwise, the responsive behavior will not work. If you need to wrap the `<si-content-action-bar>` element, you need to make sure that you define the required width in the parent container to enable the `<si-content-action-bar>` to be able to expand.

Use the [`<si-menu-bar>`](<https://element.siemens.io/components/buttons-menus/menu/>) component, if you do not need a responsive collapsible menu and only have a reduced number of menu items or use normal buttons.

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterLink } from '@angular/router';
import {
  SiApplicationHeaderComponent,
  SiHeaderBrandDirective,
  SiHeaderLogoDirective
} from '@siemens/element-ng/application-header';
import { BreadcrumbItem, SiBreadcrumbComponent } from '@siemens/element-ng/breadcrumb';
import { SiCardComponent } from '@siemens/element-ng/card';
import {
  ContentActionBarMainItem,
  SiContentActionBarComponent
} from '@siemens/element-ng/content-action-bar';
import { SiFormItemComponent } from '@siemens/element-ng/form';
import { MenuItem } from '@siemens/element-ng/menu';
import { 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';

@Component({
  selector: 'app-sample',
  imports: [
    RouterLink,
    FormsModule,
    SiApplicationHeaderComponent,
    SiBreadcrumbComponent,
    SiCardComponent,
    SiContentActionBarComponent,
    SiFormItemComponent,
    SiHeaderBrandDirective,
    SiNavbarVerticalComponent,
    SiSearchBarComponent,
    SiSidePanelComponent,
    SiSidePanelContentComponent,
    SiStatusBarComponent,
    SiHeaderLogoDirective
  ],
  templateUrl: './si-page-header.html'
})
export class SampleComponent {
  readonly breadcrumbItems: BreadcrumbItem[] = [
    { title: 'Root', link: 'root' },
    { title: 'Level 1', link: ['root', 'level1'] },
    { title: 'Level 2', link: ['root', 'level1', 'level2'] }
  ];

  readonly statusItems: StatusBarItem[] = [
    { title: 'Security', status: 'danger', value: 0 },
    { title: 'Supervisory', status: 'danger', value: 0 },
    { title: 'Not clickable', status: 'info', value: 37 }
  ];

  readonly primaryActions: ContentActionBarMainItem[] = [
    { type: 'action', label: 'Print', action: () => alert('Print') },
    { type: 'action', label: 'Share', action: () => alert('Share') },
    {
      type: 'group',
      label: 'Save As',
      children: [
        { type: 'action', label: 'Save as New Trend', action: () => alert('Save as New Trend') },
        { type: 'action', label: 'Save as a Copy', action: () => alert('Save as a Copy') },
        { type: 'action', label: 'Save as a Template', action: () => alert('Save as a Template') }
      ]
    }
  ];

  readonly secondaryActions: MenuItem[] = [
    {
      type: 'group',
      label: 'Download as',
      children: [
        { type: 'action', label: 'Image', action: () => alert('Image') },
        { type: 'action', label: 'File', action: () => alert('File') }
      ]
    },
    { type: 'action', label: 'Copy', action: () => alert('Copy') },
    { type: 'action', label: 'Hide', action: () => alert('Hide') },
    { type: 'action', label: 'Export', action: () => alert('Export') },
    { type: 'action', label: 'Favorite', action: () => alert('Favorite') }
  ];

  protected status = true;
  protected breadcrumb = true;
  protected description = true;
  protected actions = true;
  protected toolbar = true;
}
```

Template:

```html
<si-side-panel size="regular" [collapsible]="true" [enableMobile]="true">
  <div class="has-navbar-fixed-top">
    <si-application-header>
      <si-header-brand>
        <a siHeaderLogo routerLink="/"></a>
        <h1 class="application-name">Page header</h1>
      </si-header-brand>
    </si-application-header>

    <si-navbar-vertical>
      <div class="si-layout-main-padding">
        @if (status) {
          <si-status-bar class="si-layout-top-element si-layout-status" [items]="statusItems" />
        }

        @if (breadcrumb) {
          <si-breadcrumb
            class="si-layout-breadcrumb"
            [class.si-layout-top-element]="!status"
            [items]="breadcrumbItems"
          />
        }

        <div class="si-layout-header">
          <h2 class="si-layout-title" [class.si-layout-top-element]="!status && !breadcrumb"
            >Page Title</h2
          >

          @if (description) {
            <p class="si-layout-subtitle"
              >Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do</p
            >
          }

          @if (actions) {
            <si-content-action-bar
              class="si-layout-actions"
              viewType="expanded"
              [primaryActions]="primaryActions"
              [secondaryActions]="secondaryActions"
            />
          }
        </div>

        @if (toolbar) {
          <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>
        }

        <si-card heading="Page Header Controls" class="e2e-ignore">
          <div class="card-body" body>
            <si-form-item class="form-switch" label="Status">
              <input class="form-check-input" type="checkbox" [(ngModel)]="status" />
            </si-form-item>
            <si-form-item class="form-switch" label="Breadcrumb">
              <input class="form-check-input" type="checkbox" [(ngModel)]="breadcrumb" />
            </si-form-item>
            <si-form-item class="form-switch" label="Description">
              <input class="form-check-input" type="checkbox" [(ngModel)]="description" />
            </si-form-item>
            <si-form-item class="form-switch" label="Actions">
              <input class="form-check-input" type="checkbox" [(ngModel)]="actions" />
            </si-form-item>
            <si-form-item class="form-switch" label="Toolbar">
              <input class="form-check-input" type="checkbox" [(ngModel)]="toolbar" />
            </si-form-item>
          </div>
        </si-card>
      </div>
    </si-navbar-vertical>
  </div>
  <si-side-panel-content />
</si-side-panel>
```
