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:
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.
<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>