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-bgand--nb-accenton.nb-wrapinstyle.css: change the navbar color and the orange accent used by the logo, unread dots and focus rings.--nb-badgeon.nb-wrap: sets the color of the unread count pill.--nb-unread-bgon.nb-wrap: changes the highlight behind unread notifications.- Add or remove
.nb-item--unreadon any.nb-iteminindex.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-itemclick handler inscript.js: remove it and set realhrefvalues 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.