Notification Bell
React.js
medium
30 mins
Create a notification bell icon that displays a badge with the number of unread notifications and shows a dropdown list of notifications when clicked.
Requirements:
- Display a bell icon with a notification badge showing unread count
- Show dropdown list of notifications when bell is clicked
- Display notification details (title, message, timestamp)
- Mark notifications as read when clicked
- Update badge count when notifications are read
- Close dropdown when clicking outside or on bell again
- Show different styles for read/unread notifications
- Include "Mark all as read" button in dropdown
- Handle empty notification state
- Use proper accessibility attributes for screen readers
Elements and Attributes for Testing:
- Bell Icon - Must have
data-testid="notification-bell"andonClickhandler - Badge - Must display unread count and have
data-testid="notification-badge" - Dropdown - Must have
data-testid="notification-dropdown"when open - Notification Items - Must have
data-testid="notification-item"andonClickhandler - Mark All Button - Must contain text "Mark all as read" and have
onClickhandler - Empty State - Must show "No notifications" when array is empty
- Read/Unread States - Must apply different styling based on read status
Preview what you need to build
Companies:
airbnb
amazon
phonepe
Solve Similar questions 🔥
Want to upskill? Explore our courses!
Namaste DSA
Master DSA from scratch with numerous problems, and expert guidance.
Namaste React
Wanna dive deep into React and become Frontend Expert? Learn with me now!
Namaste Frontend System Design
The most comprehensive and detailed course for frontend system design.
Namaste Node.js
Wanna dive deep into Node.js? Enroll into `Namaste Node.js` now!
