StealThis .dev

Notification Bell

Notification bell icon with unread badge, dropdown notification feed, mark-as-read, mark-all-read, and grouping by Today/Earlier. No dependencies.

Open in Lab
css vanilla-js
Targets: JS HTML

Code

Notification Bell

A notification bell button with an animated unread badge counter, dropdown feed grouped by Today/Earlier, individual mark-as-read on click, mark-all-read action, and delete per item.

Features

  • Bell icon with animated red badge showing unread count
  • Dropdown notification feed with max-height scroll
  • Items grouped into “Today” and “Earlier” sections
  • Unread items have a blue dot and distinct background
  • Click an item → marks as read (dot disappears, badge decrements)
  • “Mark all as read” button clears all unread state
  • Delete (×) button removes items from the list
  • Empty state when all notifications are cleared
  • Closes on outside click or Escape

How it works

  1. Notification data is a JS array; unread count is derived by filtering .read === false
  2. renderNotifications() rebuilds the feed DOM from state on each state change
  3. Bell badge animates with a CSS scale + bounce keyframe on new notifications