A Bootstrap 5 notifications dropdown that opens from a bell icon in a dark navbar and lists recent activity with user photos, short messages, activity icons, relative times and unread dots. It fits dashboards, SaaS apps, community sites and any admin header that needs a notification center.
How it works
The wrapper .ntf-shell holds a navbar and a decorative page placeholder (.ntf-page). The bell is a button.ntf-bell with data-bs-toggle="dropdown" and data-bs-auto-close="outside", so clicks inside the menu do not close it. Because the dropdown sits inside a .navbar, Bootstrap positions the .dropdown-menu-end menu with CSS instead of Popper. Below 576px .ntf-dropdown becomes position: static and the .ntf-menu stretches across the navbar.
The menu has a .ntf-head with the title and the .ntf-mark-all button, a scrollable ul.ntf-list and a .ntf-foot link. Each a.ntf-item contains a round .ntf-photo, a .ntf-body with .ntf-text and .ntf-time, and a .ntf-dot. Unread items carry .ntf-item--unread, which tints the row and fills the dot.
The script runs on DOMContentLoaded for every .ntf-dropdown. Its update() function counts the unread items, writes the number into .ntf-badge (hidden at zero, "9+" above nine), updates the bell's aria-label and disables .ntf-mark-all when nothing is left. Clicking an unread item removes the class; clicking "Mark all as read" clears them all. If the dropdown has data-ntf-open, the menu is opened on page load with bootstrap.Dropdown.getOrCreateInstance(...).show().
The user photos come from Unsplash; replace them with your users' own avatars.
Customization
--ntf-barand--ntf-accentin.ntf-shell: change the navbar color and the accent used for links, dots and focus rings.--ntf-accent-softin.ntf-shell: sets the background of unread rows.--ntf-menu-widthin.ntf-shell: make the menu wider or narrower on larger screens.max-height: 28remin.ntf-list: limit how many rows show before the list scrolls.- Remove
data-ntf-openfrom.ntf-dropdownso the menu stays closed until the bell is clicked. - Add or remove
.ntf-item--unreadon an.ntf-itemto set the initial unread state; the badge updates itself. - The
.ntf-type--comment,.ntf-type--mentionand similar classes: recolor the small activity icons. - The comment in the
.ntf-mark-allclick handler inscript.js: add yourfetch()call to save the read state.
Use cases
- SaaS dashboards: a bell in the navbar opens recent activity with user photos and times
- Community sites: unread dots and a badge count show new comments and mentions
- Admin headers: a Mark all as read button clears every unread item at once
- Web apps: the badge and the bell label update automatically as items are read
Accessibility
The bell is a native button with an aria-label such as "Notifications, 3 unread", and the visual badge is aria-hidden. Bootstrap manages aria-expanded, Escape to close and arrow-key navigation between the links. Each unread row includes a visually-hidden "Unread" label that is removed when the row is read. A role="status" element announces "Marked as read" and "All notifications marked as read". Focus rings are visible on the bell, rows, footer and button, photos have the user's name as alt, and the hover transition is disabled with prefers-reduced-motion: reduce.
Usage notes
Requires Bootstrap 5 with its JavaScript bundle and Bootstrap Icons. Replace the # links with real URLs; the script only prevents navigation for href="#".