Tableau UI for Angular

Nav Bar

A nav bar lists an app's pages down its side, and closes to a column of icons.

Import

Import TableauUiNavBarModule from tableau-ui-angular/nav-bar.

A nav bar

tab-nav-bar holds a tab-nav-bar-header, its buttons and a tab-nav-bar-footer. [(expanded)] binds whether it is open; closed, it shows each button's icon, with its text as a tooltip and as its name for screen readers.

The header's expanded attribute is the bar's state, true or false, so its styles can show what fits; [expanded] on tab-nav-bar-header sets the header's own.

Button inputWhat it does
textRequired. The button's text
linkA router link, as routerLink takes it, through the app's router. Without one, the button is a button, and the app handles its click
[isActive]Marks the current page
[disabled]Stops the link or the click

This site's nav bar, on the left, uses links: its source is app.component.html.

My appMA

Home

The bar is open: its arrow button opens and closes it.

import { ChangeDetectionStrategy, Component, computed, signal } from '@angular/core';
import { TableauUiCommonModule } from 'tableau-ui-angular/common';
import { TableauUiIconModule } from 'tableau-ui-angular/icon';
import { TableauUiNavBarModule } from 'tableau-ui-angular/nav-bar';

interface Page {
  key: string;
  text: string;
  icon: string;
}

@Component({
  selector: 'app-nav-bar-basic-example',
  imports: [TableauUiCommonModule, TableauUiIconModule, TableauUiNavBarModule],
  templateUrl: './nav-bar-basic.example.html',
  styleUrl: './nav-bar-basic.example.scss',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NavBarBasicExampleComponent {
  protected readonly pages: readonly Page[] = [
    { key: 'home', text: 'Home', icon: 'home' },
    { key: 'reports', text: 'Reports', icon: 'table' },
    { key: 'search', text: 'Search', icon: 'search' },
  ];

  protected readonly $expanded = signal(true);
  // A button without a link runs its click; with link, it is a router link instead
  protected readonly $active = signal('home');
  protected readonly $title = computed(() => this.pages.find(page => page.key === this.$active())?.text);
}