Notification
A brief alert element used to inform users about important updates, messages, or actions.
Notification Dropdown Playground
New comment on your design
Sarah mentioned you in "Dashboard Redesign"
2 min ago
Task assigned to you
Complete the wireframes for mobile app
15 min ago
Deadline approaching
Project milestone due in 2 days
1 hour ago
Task overdue
UI review was due yesterday
3 hours ago
Design approved
Your homepage design has been approved
5 hours ago
Meeting scheduled
Team sync tomorrow at 10:00 AM
8 hours ago
Payment received
Invoice #1234 has been paid
1 day ago
Security alert
New login detected from unknown device
2 days ago
Notification Item Playground
New comment on your design
Sarah mentioned you in "Dashboard Redesign"
2 min ago
Installation
You can add the notification component to your project manually:
Install the following dependencies:
npm install class-variance-authority clsx tailwind-merge @phosphor-icons/reactCopy and paste the following code into your project.
Update the import paths to match your project setup.
Update the import aliases (e.g. @/components, @/utils) in the copied files to match your project's path configuration.
Basic Usage
Notification Dropdown
Use NotificationDropdown to display a floating list of notifications with "Mark all as Read" and "View All" actions:
import { NotificationDropdown } from '@versaui/ui/components/Notification';
const notifications = [
{
id: '1',
title: 'Meeting rescheduled',
description: 'Design sync has been moved to 3:30 PM.',
timestamp: '10m ago',
unread: true,
leadingItem: 'icon',
iconState: 'warning',
},
{
id: '2',
title: 'Sarah commented on your design',
description: '"The new glassmorphism modal looks clean!"',
timestamp: '1h ago',
unread: true,
leadingItem: 'avatar',
},
];
export function Example() {
return (
<NotificationDropdown
size="default"
notifications={notifications}
onNotificationClick={(id) => console.log('Clicked notification:', id)}
onMarkAllAsRead={() => console.log('Mark all read')}
onViewAll={() => console.log('View all notifications')}
/>
);
}Notification Item
NotificationItem can also be rendered independently in activity feeds, drawer panels, or custom menus:
import { NotificationItem } from '@versaui/ui/components/Notification';
import { CalendarBlank } from '@phosphor-icons/react';
export function Example() {
return (
<NotificationItem
size="default"
leadingItem="icon"
icon={<CalendarBlank weight="duotone" />}
iconState="warning"
title="Sprint Review scheduled"
description="Join the team sprint review meeting at 4:00 PM."
timestamp="15m ago"
unread
onClick={() => console.log('Notification clicked')}
/>
);
}Notification Icon Trigger
NotificationIcon provides a bell button trigger with an optional unread dot:
import { useState } from 'react';
import { NotificationIcon, NotificationDropdown } from '@versaui/ui/components/Notification';
export function HeaderNotification() {
const [isOpen, setIsOpen] = useState(false);
const [hasUnread, setHasUnread] = useState(true);
return (
<div className="relative">
<NotificationIcon
selected={isOpen}
notificationDot={hasUnread}
onClick={() => setIsOpen(!isOpen)}
/>
{isOpen && (
<div className="absolute right-0 top-10 z-50">
<NotificationDropdown
notifications={[/* ... */]}
onMarkAllAsRead={() => setHasUnread(false)}
/>
</div>
)}
</div>
);
}Component Props
NotificationDropdown Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | 'default' | 'large' | 'default' | Size variant of the dropdown and its child items. |
notifications | NotificationData[] | — | Array of notification data objects to render in the list. |
onNotificationClick | (id: string) => void | — | Callback invoked when a notification row is clicked. |
onMarkAllAsRead | () => void | — | Callback invoked when the "Mark all as Read" button is clicked. |
onViewAll | () => void | — | Callback invoked when the "View All" link button is clicked. |
maxHeight | number | 400 | Maximum height of the scrollable notification list in pixels. |
className | string | '' | Optional CSS class name for custom styling. |
NotificationItem Props
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | — | Primary title text (required). |
size | 'default' | 'large' | 'default' | Size variant adjusting padding, font sizes, and icon sizing. |
leadingItem | 'none' | 'icon' | 'avatar' | 'brand' | 'none' | Type of visual element displayed on the leading side. |
description | string | — | Secondary descriptive text below the title. |
timestamp | string | — | Timestamp string (e.g. "5m ago", "Yesterday"). |
unread | boolean | false | Whether the item has an unread red indicator dot. |
icon | ReactNode | — | Custom icon element when leadingItem="icon". |
iconState | 'default' | 'warning' | 'error' | 'success' | 'warning' | Visual state container color for the leading icon. |
avatar | ReactNode | — | Avatar element when leadingItem="avatar". |
brand | ReactNode | — | Brand icon element when leadingItem="brand". |
onClick | () => void | — | Click handler called when the notification item is clicked. |
className | string | '' | Optional CSS class name. |
NotificationIcon Props
| Prop | Type | Default | Description |
|---|---|---|---|
selected | boolean | false | Controls whether the trigger button displays the active/selected border state. |
notificationDot | boolean | false | Whether to show the red notification status badge dot. |
onClick | () => void | — | Click handler when the icon button is clicked. |
className | string | '' | Optional CSS class name. |