Bootstrap 5 sticky navbars keep navigation visible as users scroll. This page covers 4 sticky navbar patterns — sticky-top, fixed-top, shrink on scroll and transparent to solid — each with working JavaScript.
Quick Setup
Sticky navbars need only Bootstrap 5 CSS for sticky-top. Scroll effects need JS:
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
Key Classes Reference
| Class | What It Does |
|---|---|
.sticky-top | Sticks to top when scrolled past |
.fixed-top | Always pinned to top of viewport |
.fixed-bottom | Always pinned to bottom |
position: sticky | CSS sticky positioning |
top: 0 | Required for sticky to work |
z-index: 1020 | Bootstrap's default navbar z-index |
.shadow-sm | Subtle shadow on scrolled navbar |
1. Bootstrap 5 sticky-top Navbar
The simplest sticky navbar. Sticks to top when scrolled past it. Stays in document flow — no body padding needed.
2. Bootstrap 5 fixed-top Navbar
Always visible at the top using fixed-top. Removed from document flow — add padding-top:56px to body.
3. Bootstrap 5 Navbar Shrink on Scroll
Navbar that shrinks padding and font size when user scrolls down. Common on marketing sites.
4. Bootstrap 5 Transparent to Solid Navbar on Scroll
Navbar starts transparent over a hero image and becomes solid white with shadow when scrolling.
Frequently Asked Questions
Need a Full Bootstrap 5 Admin Dashboard?
Get a complete Angular 21 + Bootstrap 5 dashboard with 50+ components — built by the same team behind BootstrapPlanet.
Browse Templates →Use code FIRST30 for 30% off your first purchase.