Skip to content

Navbar with Notification Bell and Badge Count

Dark Bootstrap 5 navbar with a notification bell, live unread count badge and a dropdown list that marks items as read.

Also known as: navbar notification bell, notification badge navbar, unread count bell icon, navbar with notifications, header notification dropdown

Navbar with Notification Bell and Badge Count live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A dark Bootstrap 5 navbar with a notification bell, an unread count badge and a dropdown list of recent activity. Use it in dashboards, SaaS apps and admin panels where users need to see new comments, assignments or system events at a glance.

How it works

The root .nb-wrap holds a nav.navbar.nb-navbar with the brand, a collapsible link list (#nb-menu) and a right-hand group that stays visible on every screen size: the bell, the profile avatar and the navbar toggler. The bell is a button.nb-bell with data-bs-toggle="dropdown" and data-bs-auto-close="outside", so clicks inside the .nb-menu panel do not close it. The red .nb-count pill sits on the bell's corner.

Each notification is an a.dropdown-item.nb-item with an avatar (.nb-avatar) or icon (.nb-icon), a message, a timestamp and an orange .nb-dot. Unread items carry .nb-item--unread, which gives them a warm background. The script counts those items on DOMContentLoaded, writes the number into .nb-count, hides the badge at zero and updates the bell's aria-label. Clicking an item removes .nb-item--unread; clicking .nb-mark-all clears every item at once and then disables the button. While unread items exist, .nb-wrap--ring plays a single bell-shake animation.

On screens below 576px the panel is pinned to both edges of the navbar instead of the bell, so it never overflows the viewport. The avatars are Unsplash photos; replace them with your own users' images.

Customization

  • --nb-bg and --nb-accent on .nb-wrap in style.css: change the navbar color and the orange accent used by the logo, unread dots and focus rings.
  • --nb-badge on .nb-wrap: sets the color of the unread count pill.
  • --nb-unread-bg on .nb-wrap: changes the highlight behind unread notifications.
  • Add or remove .nb-item--unread on any .nb-item in index.html: the badge count updates automatically on load.
  • data-nb-open-on-load="true" on .nb-navbar: opens the dropdown on page load for the demo; remove it in production so the panel starts closed.
  • width: min(23rem, calc(100vw - 1.5rem)) in .nb-menu: makes the notification panel wider or narrower on desktop.
  • The event.preventDefault() line in the .nb-item click handler in script.js: remove it and set real href values so each notification opens its page.

Use cases

  • Web app headers: a bell with an unread count badge sits in a dark navbar
  • Dashboards: a dropdown list shows recent items that can be marked as read
  • Community platforms: the badge count drops as users read notifications
  • Admin consoles: a compact notification entry point keeps the navbar uncluttered

Accessibility

The bell button has an aria-label such as "Notifications, 3 unread" that the script keeps in sync, and the visual badge is aria-hidden to avoid double reading. Unread items include a visually-hidden "Unread" label, which is removed when the item is read. A role="status" live region .nb-live announces the new count after marking items as read. Bootstrap handles the arrow-key navigation and Escape for the dropdown. All controls show a visible focus outline, and the ring animation is disabled under prefers-reduced-motion.

Usage notes

Requires Bootstrap 5 with its JS bundle (added automatically) and Bootstrap Icons. For several navbars on one page, give each collapse a unique id and matching data-bs-target.

Navbar with Notification Bell and Badge Count at a glance

Framework
Bootstrap 5
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 5, Bootstrap Icons
Layout
Responsive, works on mobile, dark design
Category
Navbars
License
Free for personal and commercial use

Questions about this template

Can I use the Navbar with Notification Bell and Badge Count 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, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

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">
Navbar with Notification Bell and Badge Count – free Bootstrap 5 navbar template
Navbar with Notification Bell and Badge Count · 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.