Navbar

bs-navbar renders Bootstrap's navbar markup from the headless @mintplayer/ui-core/navbar core, server-side included. The responsive collapse is a checkbox and every dropdown a native <details>, so the bar works with JavaScript off. Mark the brand with *bsNavbarBrand, group entries in a bs-navbar-nav (align="end" pushes a group to the far edge), and use bs-navbar-item for an entry in a group. A dropdown is the same bs-dropdown-menu / bs-dropdown-item pair a standalone dropdown uses: inside a nav group it renders the navbar's <details> disclosure, nested menus become submenus, and its label is the trigger text (the *bsDropdownMenuLabelTemplate template takes any HTML; give an icon-only label an aria-label). Without JavaScript a dropdown also opens while keyboard focus is inside it. A custom hamburger glyph is the *bsNavbarToggler template. expanded is two-way: [(expanded)] follows every toggle of the collapse.

Basic usage

  
    
      
        <bs-navbar [breakpoint]="'lg'" [color]="'body-tertiary'" aria-label="Main navigation" [(expanded)]="expanded">
        
    
      
            <a *bsNavbarBrand routerLink="/">MyApp</a>
        
    
      
        
        
    
      
          <bs-navbar-nav>
        
    
      
            <bs-navbar-item [active]="true">
        
    
      
              <a routerLink="/">Home</a>
        
    
      
            </bs-navbar-item>
        
    
      
            <bs-navbar-item>
        
    
      
              <a routerLink="/about">About</a>
        
    
      
            </bs-navbar-item>
        
    
      
        
        
    
      
            <bs-dropdown-menu label="Products">
        
    
      
              <bs-dropdown-item><a routerLink="/products/widgets">Widgets</a></bs-dropdown-item>
        
    
      
              <bs-dropdown-item><a routerLink="/products/gadgets">Gadgets</a></bs-dropdown-item>
        
    
      
              <bs-dropdown-item><a routerLink="/products/gizmos">Gizmos</a></bs-dropdown-item>
        
    
      
            </bs-dropdown-menu>
        
    
      
          </bs-navbar-nav>
        
    
      
        
        
    
      
          <bs-navbar-nav align="end">
        
    
      
            <bs-navbar-item>
        
    
      
              <a routerLink="/sign-in">Sign in</a>
        
    
      
            </bs-navbar-item>
        
    
      
          </bs-navbar-nav>
        
    
      
        </bs-navbar>
        
    
  
    
      
        import { Component, signal } from '@angular/core';
        
    
      
        import { RouterLink } from '@angular/router';
        
    
      
        import {
        
    
      
          BsNavbarComponent,
        
    
      
          BsNavbarNavComponent,
        
    
      
          BsNavbarItemComponent,
        
    
      
          BsNavbarBrandDirective,
        
    
      
          BsNavbarLinkDirective,
        
    
      
        } from '@mintplayer/ng-bootstrap/navbar';
        
    
      
        import { BsDropdownItemComponent, BsDropdownMenuComponent } from '@mintplayer/ng-bootstrap/dropdown';
        
    
      
        
        
    
      
        @Component({
        
    
      
          selector: 'my-navbar-demo',
        
    
      
          templateUrl: './my-navbar-demo.component.html',
        
    
      
          imports: [
        
    
      
            RouterLink,
        
    
      
            BsNavbarComponent,
        
    
      
            BsNavbarNavComponent,
        
    
      
            BsNavbarItemComponent,
        
    
      
            BsNavbarBrandDirective,
        
    
      
            BsDropdownMenuComponent,
        
    
      
            BsDropdownItemComponent,
        
    
      
            BsNavbarLinkDirective,
        
    
      
          ],
        
    
      
        })
        
    
      
        export class MyNavbarDemoComponent {
        
    
      
          readonly expanded = signal(false);
        
    
      
        }