Header

A site's top bar, the page's banner: your brand, the Navigation Menu's links and your actions; on narrow screens a toggle and a menu that covers the page below the bar. It can stay at the top, or slide away as the page scrolls. For an app's navigation beside the page, use a Sidebar.

NavigationExperimental

Usage

import { Component, ViewEncapsulation, signal } from '@angular/core';import { RouterLink } from '@angular/router';import {  ScHeader,  ScHeaderMobileMenu,  ScHeaderMobileMenuToggle,  ScLink,  ScNavigationMenu,  ScNavigationMenuItem,  ScNavigationMenuLink,  ScNavigationMenuList,} from '@semantic-components/ui';import {  SiGalleryVerticalEndIcon,  SiMenuIcon,  SiXIcon,} from '@semantic-icons/lucide-icons';
@Component({  selector: 'app-header-usage-demo',  imports: [    RouterLink,    ScHeader,    ScHeaderMobileMenu,    ScHeaderMobileMenuToggle,    ScLink,    ScNavigationMenu,    ScNavigationMenuItem,    ScNavigationMenuLink,    ScNavigationMenuList,    SiGalleryVerticalEndIcon,    SiMenuIcon,    SiXIcon,  ],  template: `    <header scHeader class="border-b-0" #header="scHeader">      <a        class="flex items-center gap-2 font-semibold [&>svg]:size-6"        routerLink="."      >        <svg siGalleryVerticalEndIcon></svg>        Acme      </a>
      <nav scNavigationMenu aria-label="Main">        <ul scNavigationMenuList>          @for (link of links; track link) {            <li scNavigationMenuItem>              <a                scNavigationMenuLink                routerLink="."                [active]="link === current()"                (click)="go($event, link)"              >                {{ link }}              </a>            </li>          }        </ul>      </nav>
      <div class="ms-auto flex items-center gap-2">        <a scLink variant="button" routerLink=".">Get started</a>        <button scHeaderMobileMenuToggle class="-me-2">          @if (header.mobileMenuOpen()) {            <svg siXIcon></svg>            <span class="sr-only">Close menu</span>          } @else {            <svg siMenuIcon></svg>            <span class="sr-only">Open menu</span>          }        </button>      </div>
      <ng-template scHeaderMobileMenu>        <nav aria-label="Main">          @for (link of links; track link) {            <a              scNavigationMenuLink              routerLink="."              [active]="link === current()"              (click)="go($event, link)"            >              {{ link }}            </a>          }        </nav>      </ng-template>    </header>    <main class="space-y-2 p-6">      <h1 class="text-2xl font-semibold">{{ current() }}</h1>      <p class="text-muted-foreground text-sm">        Narrow the window: the links move into the menu, behind the toggle.      </p>    </main>  `,  // The page under the bar: gray, the frame's height.  host: { class: 'bg-muted block min-h-dvh' },  encapsulation: ViewEncapsulation.None,})export class HeaderUsageDemo {  private readonly links = ['Products', 'Pricing', 'Docs', 'Blog'];  private readonly current = signal('Products');
  /** A demo: the link marks its page, and stays here. */  private go(event: Event, link: string): void {    event.preventDefault();    this.current.set(link);  }}

Anatomy

The bar holds your brand, the links — a Navigation Menu, shown from the expand width up — and your actions, your own markup laid out as you like. Below the expand width, the header shows the mobile menu's toggle, wherever you put it (here, with your actions), and hides the links. The menu is an ng-template: the header renders it while it is open, and removes it on closing.

import { ScHeader, ScHeaderMobileMenu, ScHeaderMobileMenuToggle, ScNavigationMenu, ScNavigationMenuItem, ScNavigationMenuLink, ScNavigationMenuList } from '@semantic-components/ui';
<header scHeader #header="scHeader">  <a href="/">…</a>  <!-- your brand: your own link -->
  <!-- The links: a Navigation Menu, from the expand width up -->  <nav scNavigationMenu aria-label="Main">    <ul scNavigationMenuList>      <li scNavigationMenuItem>        <a scNavigationMenuLink [active]="…">…</a>      </li>    </ul>  </nav>
  <!-- Your actions: your own layout -->  <div class="ms-auto flex items-center gap-2">    …    <!-- Below the expand width only: the toggle of the mobile menu -->    <button scHeaderMobileMenuToggle class="-me-2">      @if (header.mobileMenuOpen()) {        <svg siXIcon></svg><span class="sr-only">Close menu</span>      } @else {        <svg siMenuIcon></svg><span class="sr-only">Open menu</span>      }    </button>  </div>
  <ng-template scHeaderMobileMenu>    <nav aria-label="Main">      <a scNavigationMenuLink [active]="…">…</a>    </nav>  </ng-template></header>

Accessibility

  • The bar is the page's banner landmark (a header element); name it with aria-label only if the page has more than one.
  • Name both navs (aria-label): the links and the menu's. Only one of them is in the page at a time, so they can share a name.
  • The toggle is a disclosure: aria-expanded, and aria-controls while the menu is open. Its name follows the state — "Open menu", "Close menu" — in a sr-only span beside your icons.
  • Not modal: nothing is trapped. Escape closes the menu and gives the focus back to the toggle; following a link closes it too, and, over the page, a click or the focus outside the bar.
  • With reduced motion, nothing animates: the menu opens and closes at once, and hiding on scroll hides without sliding.

Examples

The header adapts to the viewport, so each example runs in its own frame.

Basic

import { Component, ViewEncapsulation, signal } from '@angular/core';import { RouterLink } from '@angular/router';import {  ScHeader,  ScHeaderMobileMenu,  ScHeaderMobileMenuToggle,  ScLink,  ScNavigationMenu,  ScNavigationMenuItem,  ScNavigationMenuLink,

Mobile Menu

import { Component, ViewEncapsulation, signal } from '@angular/core';import { RouterLink } from '@angular/router';import {  ScHeader,  ScHeaderMobileMenu,  ScHeaderMobileMenuToggle,  ScLink,  ScNavigationMenu,  ScNavigationMenuItem,  ScNavigationMenuLink,

Push Menu

import { Component, ViewEncapsulation, signal } from '@angular/core';import { RouterLink } from '@angular/router';import {  ScHeader,  ScHeaderMobileMenu,  ScHeaderMobileMenuToggle,  ScNavigationMenu,  ScNavigationMenuItem,  ScNavigationMenuLink,  ScNavigationMenuList,

With a Navigation Menu

import { Component, ViewEncapsulation, signal } from '@angular/core';import { RouterLink } from '@angular/router';import {  ScHeader,  ScHeaderMobileMenu,  ScHeaderMobileMenuToggle,  ScNavigationMenu,  ScNavigationMenuContent,  ScNavigationMenuItem,  ScNavigationMenuLink,

Sticky, Hides on Scroll

import { Component, ViewEncapsulation, signal } from '@angular/core';import { RouterLink } from '@angular/router';import {  ScHeader,  ScHeaderMobileMenu,  ScHeaderMobileMenuToggle,  ScNavigationMenu,  ScNavigationMenuItem,  ScNavigationMenuLink,  ScNavigationMenuList,

RTL

import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation, signal } from '@angular/core';import { RouterLink } from '@angular/router';import {  ScHeader,  ScHeaderMobileMenu,  ScHeaderMobileMenuToggle,  ScNavigationMenu,  ScNavigationMenuItem,  ScNavigationMenuLink,

API reference

The header and the toggle take class, merged over their own (cn: a later class wins). The menu's template has no element of its own: style the content you put in it.

PartSelectorDescription
ScHeaderheader[scHeader] The bar, the page's banner, 56px tall (more when the menu pushes the page): [(mobileMenuOpen)] the mobile menu's state; expand ('sm', 'md', 'lg' — the width from which its links show, 'md' by default: its nav, a Navigation Menu, is hidden below it); mobileMenu ('cover' over the page below the bar, by default, or 'push' pushing it down); sticky; hideOnScroll (away going down, back going up). exportAs scHeader. Renders your menu while open, and closes it on Escape, a link followed (at once), a navigation ending, the window growing wide enough, and (covering the page) a click or the focus outside the bar.
ScHeaderMobileMenuTogglebutton[scHeaderMobileMenuToggle] Opens and closes the menu, below expand: aria-expanded, aria-controls while open. Your icons and a name that follows the state (sr-only). The style's button: variant ('ghost'), size ('icon'). Where it sits is yours (ms-auto to reach the end, -me-2 to line its icon up with the edge).
ScHeaderMobileMenung-template[scHeaderMobileMenu] The menu's content — a named nav with its links (scNavigationMenuLink: the Navigation Menu's link, with its states; following one closes the menu), any actions — rendered by the header while open, in its panel: over the page below the bar, see-through and blurred, opening at once, fading out in 100ms — or, with the header's mobileMenu set to 'push', pushing the page down. No class: the template has no element; style the content you put in it.