Navbar

Ready-to-copy navigation bar variants - a mobile slide-out menu with no JavaScript, and a transparent navbar that becomes sticky on scroll.

Offcanvas Mobile Menu (Zero JS)

The menu slides in from the right edge of the screen via the Checkbox Hack - shrink your browser window to see the effect.

<nav class="navbar">
  <div class="container navbar-container">
    <!-- 1. Hidden checkbox and backdrop - MUST be siblings of
         .navbar-toggle and .navbar-menu-offcanvas below -->
    <input type="checkbox" id="nav-toggle" class="navbar-offcanvas-toggle">
    <label for="nav-toggle" class="navbar-offcanvas-backdrop"></label>

    <a href="#" class="navbar-brand">Logo</a>

    <!-- 2. Hamburger as a label -->
    <label for="nav-toggle" class="navbar-toggle">
      <span></span><span></span><span></span>
    </label>

    <!-- 3. Menu with the offcanvas class -->
    <div class="navbar-menu navbar-menu-offcanvas">
      <a href="#" class="navbar-item">Link 1</a>
      <a href="#" class="navbar-item">Link 2</a>
    </div>
  </div>
</nav>

Transparent Sticky Navbar

A menu that's transparent by default (ideal over dark Hero photos), which gains a background and sticks to the top once scrolled.

Hero Section

<!-- Just the navbar-transparent class. Don't add navbar-sticky:
     sticky returns to the document flow and the overlay effect disappears. -->
<nav class="navbar navbar-transparent">
  <div class="container navbar-container">
    <a href="#" class="navbar-brand">Logo</a>
    <div class="navbar-menu">
      <a href="#" class="navbar-item">White link</a>
    </div>
  </div>
</nav>

<!-- The navbar is out of flow, so push the hero content down -->
<header style="padding-top: calc(var(--navbar-h) + 4rem)">…</header>

Navbar "Pill" (Floating Pill) New

Navigation as a pill floating off the edge, sitting on top of the content - this means the hero photo starts right from the top of the page, instead of below the bar. Once scrolled, the pill unfolds into a regular bar at the edge and returns to the theme colors.

The photo starts from the top

<nav class="navbar navbar-pill">
  <div class="container navbar-container">
    <a href="#" class="navbar-brand">Logo</a>
    <div class="navbar-menu">
      <a href="#" class="navbar-item">Offer</a>
    </div>
  </div>
</nav>

<!-- The navbar is out of flow - push the hero content down -->
<header style="padding-top: calc(var(--navbar-h) + 4rem)">…</header>

<!-- Both states are controlled separately, no CSS writing needed: -->
<nav class="navbar navbar-pill" style="
       --navbar-pill-bg: #4c1d95;
       --navbar-pill-color: #fff;
       --navbar-pill-bg-scrolled: #1e293b;
       --navbar-pill-color-scrolled: #fff;">

Things to remember:

  • Don't combine with navbar-sticky. Sticky returns to the document flow and the entire overlay effect disappears. The .is-scrolled class is added automatically by JS.
  • Push the hero content down by var(--navbar-h) - the navbar is position: absolute, so without this the heading would sit under the pill.
  • The pill is dark by default (it sits over a photo), even in light mode - that's why its background is a literal value, not var(--dark), which lightens in dark mode.
  • Logo: if you have a light and dark version (.logo-light / .logo-dark), the light one shows over the pill, and the theme-matching one after scrolling.

Variables - both states separately

Variable Default Controls
--navbar-pill-bg #1e293b pill background over the hero
--navbar-pill-color #fff links, brand, and hamburger over the hero
--navbar-pill-bg-scrolled var(--bg-surface) bar background after scrolling
--navbar-pill-color-scrolled var(--text-main) text after scrolling
--navbar-pill-padding-x 32px content padding inside the pill
--navbar-pill-padding-x-scrolled 16px padding after scrolling (aligned with .container)

Each state has its own variable (instead of overriding the base one), because an inline style beats a class rule - a single shared variable would block the other state.

Topbar

A narrow bar with contact details or links, placed above the main navbar - typical for B2B/corporate sites.

  • +1 555 123 4567
  • contact@molique.com
<div class="topbar">
  <div class="container topbar-content">
    <ul class="topbar-list">
      <li><svg class="icon" aria-hidden="true"><use href="img/icons-sprite.svg#ph-phone"></use></svg> +1 555 123 4567</li>
    </ul>
    <ul class="topbar-list">
      <li><a href="#">Login</a></li>
    </ul>
  </div>
</div>