Navbar

A navbar is a top bar that is typically placed at the top of a page. It's sticky by default, but can be changed to be non-sticky.

Examples

Basic usage

<header class="navbar">
            <div class="cluster is-between">
                <a href="#" class="nav-link is-brand"><strong>Acme</strong></a>
                <nav class="cluster" aria-label="Primary">
                    <a href="#" class="nav-link" aria-current="page">Docs</a>
                    <a href="#" class="nav-link">Components</a>
                    <a href="#" class="nav-link">Blog</a>
                </nav>
                <div class="cluster">
                    <button class="button is-ghost" type="button">Sign in</button>
                    <button class="button" type="button">Sign up</button>
                </div>
            </div>
        </header>

With a subnavbar

<header class="navbar">
            <div class="cluster is-between">
                <a href="#" class="nav-link is-brand"><strong>Acme</strong></a>
                <nav class="cluster" aria-label="Primary">
                    <a href="#" class="nav-link" aria-current="page">Docs</a>
                    <a href="#" class="nav-link">Components</a>
                </nav>
            </div>
        </header>
        <nav class="subnavbar" aria-label="Section">
            <div class="breadcrumb">
                <ol>
                    <li><a href="#">Home</a></li>
                    <li><a href="#">Products</a></li>
                    <li><span aria-current="page">Widget</span></li>
                </ol>
            </div>
        </nav>

Token overrides

The bar's whole look is four tokens: background, border color, border width, and padding. Restate them per project -- or per page -- and the component follows; no variant classes needed.

<header class="navbar" style="--navbar-bg: var(--color-fill); --navbar-border-width: 0">
            <div class="cluster is-between">
                <a href="#" class="nav-link is-brand"><strong>Acme</strong></a>
                <div class="cluster">
                    <button class="button is-ghost is-sm" type="button">Help</button>
                    <button class="button is-sm" type="button">Account</button>
                </div>
            </div>
        </header>

Without the bottom border

<header class="navbar no-border">
            <div class="cluster is-between">
                <a href="#" class="nav-link is-brand"><strong>Acme</strong></a>
                <div class="cluster">
                    <button class="button is-ghost" type="button">Help</button>
                    <button class="button" type="button">Account</button>
                </div>
            </div>
        </header>

Source comments

Navbar -- sticky top bar.

Layout INSIDE the navbar is the consumer's concern -- compose with
the primitives brio already ships. Typical shape:

  <header class="navbar">
    <nav class="center cluster is-between">
      <a href="/">Logo</a>
      <div class="cluster">
        <a class="nav-link" aria-current="page">Home</a>
        <a class="nav-link">Products</a>
      </div>
      <div class="cluster is-end">
        <button class="button">Sign in</button>
      </div>
    </nav>
  </header>

The navbar layout (first & last children expand equally, middle items
cluster in the center) is a composition-primitive concern -- see
.cluster.is-between in composition.css.

Reference

Source: src/css/navbar.css

.navbar

ClassKindDescription
.no-borderopt-outRemoves the bottom border
TokenDefaultDescription
--navbar-bgvar(--color-surface)Background color for the navbar
--navbar-border-colorvar(--color-border-subtle)Border color for the navbar's bottom edge
--navbar-border-widthvar(--border-width-default)Border width for the navbar's bottom edge
--navbar-padding-blockvar(--ui-pad-block-relaxed)Block-axis inner padding for the navbar
--navbar-padding-inlinevar(--ui-pad-inline-relaxed)Inline-axis inner padding for the navbar
--navbar-positionstickyPositioning for the navbar

Related: Subnavbar

Sticky secondary bar below the navbar

Source: src/css/navbar.css

.subnavbar

ClassKindDescription
.no-borderopt-outRemoves the bottom border
TokenDefaultDescription
--subnavbar-bgvar(--color-surface)Background color for the subnavbar
--subnavbar-border-colorvar(--color-border-subtle)Border color for the subnavbar's bottom edge
--subnavbar-border-widthvar(--border-width-default)Border width for the subnavbar's bottom edge
--subnavbar-padding-blockvar(--ui-pad-block-snug)Block-axis inner padding for the subnavbar
--subnavbar-padding-inlinevar(--ui-pad-inline-snug)Inline-axis inner padding for the subnavbar
--subnavbar-positionstickyPositioning for the subnavbar
--navbar-height4remSticky offset from the top, this is meant to be set on navbar or :root