Skip to content

Bootstrap Navbar with Search and Dropdown

Responsive Bootstrap 5 navbar with brand, dropdown menu, search form and user actions.

Also known as: navbar with search bar, navigation bar with dropdown, header with search and login, responsive top menu

Bootstrap 5 Navbars Responsive #dropdown #navbar #responsive #search

Bootstrap Navbar with Search and Dropdown live demo

Open in new tab

Bootstrap 5 code (HTML, CSS)

A Bootstrap 5 navbar with a brand logo, a Products dropdown, an inline search field, a notification bell with an unread badge and a sign-in button. It fits SaaS dashboards, marketing sites and web apps that need search and account actions in the header.

How it works

The root is a nav with Bootstrap's navbar navbar-expand-lg classes plus the scoping class .ns-navbar. Inside a .container sit the navbar-brand link with an icon tile .ns-logo, the navbar-toggler button and the collapsible area #ns-menu. The collapse contains a navbar-nav list with a dropdown item, the search form .ns-search built on an input-group, and a group with the bell button and the primary Sign in link.

There is no custom JavaScript. Bootstrap's bundle handles everything through data attributes: data-bs-toggle="collapse" with data-bs-target="#ns-menu" opens and closes the mobile menu, and data-bs-toggle="dropdown" opens the Products menu. Below the lg breakpoint the links, search and buttons stack inside the collapsed panel; from lg up they line up in one row and me-auto pushes the search and buttons to the right. The small style.css only sizes the .ns-logo tile, gives .ns-search a min-width of 220px and adds vertical padding to .dropdown-item.

Customization

  • navbar-expand-lg on the nav: change to navbar-expand-md or navbar-expand-xl to switch to the horizontal layout at a different width.
  • background: var(--bs-primary) in .ns-navbar .ns-logo: set your own color for the logo tile, or replace the bi-lightning-charge-fill icon.
  • bg-white on the nav: swap for bg-body-tertiary or add data-bs-theme="dark" with bg-dark for a dark header.
  • min-width: 220px in .ns-navbar .ns-search: make the search field wider or narrower on desktop.
  • The badge bg-danger span inside the bell button: change the number, color or remove it; update the button's aria-label to match.
  • btn-primary on the Sign in link: use btn-outline-primary or btn-dark for a different call-to-action style.
  • Add or remove dropdown-item entries and dropdown-divider in the dropdown-menu to change the Products list.

Use cases

  • SaaS dashboards: a Products dropdown and search field keep key navigation in one header
  • Marketing sites: the brand, dropdown menu and sign-in button sit in a responsive top bar
  • Web apps with notifications: a bell button with an unread badge sits beside the search field
  • Mobile layouts: links, search and buttons stack inside a collapsible panel below the large breakpoint

Accessibility

The nav has aria-label="Main navigation", and the toggler carries aria-controls, aria-expanded and aria-label, which Bootstrap updates when the menu opens. The active link uses aria-current="page". The search form has role="search" and a visually-hidden label tied to #ns-search-input. The bell button announces "Notifications, 3 unread" while the visual badge is aria-hidden, and all decorative Bootstrap Icons are hidden from assistive technology. Bootstrap's dropdown supports arrow keys and Escape.

Usage notes

Requires Bootstrap 5 CSS and JS bundle (added automatically) and Bootstrap Icons, which is listed as an external library. If you use two navbars on one page, give the collapse a different id and update data-bs-target and aria-controls.

Bootstrap Navbar with Search and Dropdown at a glance

Framework
Bootstrap 5
Code
HTML, CSS
JavaScript
Only Bootstrap 5's own script
Dependencies
Bootstrap 5, Bootstrap Icons
Layout
Responsive, works on mobile
Category
Navbars
License
Free for personal and commercial use

Questions about this template

Can I use the Bootstrap Navbar with Search and Dropdown code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 5 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear and add the CSS to your stylesheet. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. Only Bootstrap 5's own JavaScript is used, and the download already includes it.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  • <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Bootstrap Navbar with Search and Dropdown – free Bootstrap 5 navbar template
Bootstrap Navbar with Search and Dropdown · free Bootstrap 5 navbar template

More Navbars

Navbar with Sliding Active Indicator – free Pure CSS navbar template

Navbar with Sliding Active Indicator

Dark responsive navbar with a glowing underline that slides between links on hover, focus and click, built with CSS custom properties and vanilla JS.

Navbar with Offcanvas Drawer on Mobile – free Bootstrap 6 navbar template

Navbar with Offcanvas Drawer on Mobile

Responsive Bootstrap 6 navbar that shows inline links on desktop and moves them into a slide-in Drawer with icons, studio hours and social links on small screens.

Navbar with Overflow Menu (NavOverflow) – free Bootstrap 6 navbar template

Navbar with Overflow Menu (NavOverflow)

Bootstrap 6 news navbar built on the new NavOverflow component: links that do not fit move into a More menu automatically as the width shrinks.