A dark Bootstrap 6 notifications dropdown that opens from a bell icon in an app header. It lists recent activity with avatars or status icons, highlights unread items with a coral dot, and offers an All/Unread filter, relative timestamps and a "Mark all as read" button. The bell's counter updates as items are read.
How it works
The bell .ntf-bell is an icon button with data-bs-toggle="menu", data-bs-placement="bottom-end" and data-bs-auto-close="outside", so the menu stays open while you read, filter or clear items. The .ntf-menu holds a header, a Bootstrap 6 radio button group (.btn-group with label.btn-check around each input), the notification items, an empty state and a "View all" link.
Each notification is an a.menu-item.ntf-item placed directly inside the menu, which keeps the Menu plugin's arrow-key navigation working. The item contains a .avatar (a photo, or an icon with avatar-subtle theme-success, theme-info or theme-warning), a .menu-item-content block and a .ntf-dot. Unread items carry .ntf-unread and a visually hidden "Unread." label for screen readers.
script.js turns each data-ntf-mins value into a real datetime and a phrase from Intl.RelativeTimeFormat ("4 minutes ago", "yesterday"), so the demo never shows stale dates. A render() function counts unread items and updates .ntf-badge, .ntf-filter-count, the bell's aria-label and the disabled state of .ntf-read-all. It also hides read items under the Unread filter and shows .ntf-empty when nothing is left. Clicking an item marks it read. For the preview, the menu opens on load and .ntf-instant skips the fade-in.
Customization
- Remove
data-ntf-open-on-loadfrom.ntf-rootso the dropdown starts closed. --ntf-accentand--ntf-accent-softon.ntf-root: recolor the badge, unread dots, unread background and links.--ntf-surface,--ntf-barand--ntf-pageon.ntf-root: change the menu, header and page colors.widthon.ntf-menu: make the panel wider than the default 24rem.- Replace
data-ntf-minswith timestamps from your API and pass the difference in minutes torelative(). - Replace
preventDefault()in the item click handler with navigation, and send afetch()request to save the read state on your server.
Use cases
- App navigation bars: a bell with an unread count shows what needs attention
- Dashboards: an All and Unread filter helps users focus on new items
- Social and team apps: relative timestamps show how recent each notification is
- Inbox-style menus: a mark all as read button clears the unread dots at once
Accessibility
The bell's aria-label always states the unread count, and the Menu plugin keeps its aria-expanded current. Arrow keys move between notifications and Escape returns focus to the bell. The filter is a labelled radio group, unread state is spoken through hidden text, and "Mark all as read" is announced in a polite live region. Times are real <time> elements, decorative icons are aria-hidden, and items show a coral focus outline.
Bootstrap 6 notes
Bootstrap 5's .dropdown-menu-end and data-bs-toggle="dropdown" become data-bs-placement="bottom-end" on a data-bs-toggle="menu" button. Toggle buttons now wrap the input in label.btn-check, and colored avatars use .avatar with theme-*. Built on Bootstrap 6.0.0-alpha.1, so alpha APIs can still change. Icons come from Bootstrap Icons, and the portraits are from Unsplash; replace them with your own images.