NotificationCenter
A notification center component with a trigger bell, category tabs, mark-as-read, infinite scroll, and customizable panel layout.
Basic Usage
Notification Bell
Click the bell icon to open the notification panel. Unread count is shown as a badge.
import { NotificationCenter } from 'fluxo-ui';
import type { NotificationItem } from 'fluxo-ui';
const [items, setItems] = useState<NotificationItem[]>([...]);
<NotificationCenter
items={items}
onItemClick={(item) => console.log('Clicked:', item.title)}
onMarkRead={(id) => markAsRead(id)}
onMarkAllRead={() => markAllRead()}
onClear={() => setItems([])}
/>Categories
Pass a categories array to enable tab-based filtering. An "All" tab is automatically prepended.
Category Tabs
Filter notifications by category using tab buttons. The 'All' tab shows everything.
import { NotificationCenter } from 'fluxo-ui';
<NotificationCenter
items={items}
categories={['Updates', 'Social', 'Alerts']}
onItemClick={(item) => console.log(item)}
onMarkRead={(id) => markAsRead(id)}
onMarkAllRead={() => markAllRead()}
/>Custom Trigger
Use triggerElement to replace the bell icon. Customize header, footer, width, and maxHeight.
Custom Trigger & Layout
Replace the default bell icon with any element. Customize header, footer, width, and max height.
import { NotificationCenter, Button } from 'fluxo-ui';
<NotificationCenter
items={items}
triggerElement={<Button variant="primary" size="sm">Notifications</Button>}
header={<div className="p-3 font-bold text-lg">My Alerts</div>}
footer={<div className="p-3 text-center text-sm">View all notifications</div>}
width="420px"
maxHeight="300px"
/>Import
import { NotificationCenter } from 'fluxo-ui';
import type { NotificationCenterProps, NotificationItem } from 'fluxo-ui';NotificationCenter Props
itemsreqNotificationItem[]Array of notification items.
itemsreqNotificationItem[]Array of notification items.
categoriesstring[]Category names for tab filtering.
categoriesstring[]Category names for tab filtering.
unreadCountnumberOverride the auto-computed unread badge count.
unreadCountnumberOverride the auto-computed unread badge count.
onItemClick(item: NotificationItem) => voidCalled when a notification is clicked.
onItemClick(item: NotificationItem) => voidCalled when a notification is clicked.
onMarkRead(id: string) => voidCalled when marking a single notification as read.
onMarkRead(id: string) => voidCalled when marking a single notification as read.
onMarkAllRead() => voidCalled when "Mark all read" is clicked.
onMarkAllRead() => voidCalled when "Mark all read" is clicked.
onClear() => voidCalled when "Clear all" is clicked.
onClear() => voidCalled when "Clear all" is clicked.
onLoadMore() => Promise<void>Called when scrolling near the bottom to load more.
onLoadMore() => Promise<void>Called when scrolling near the bottom to load more.
hasMoreboolean"false"Whether more notifications can be loaded.
hasMoreboolean"false"Whether more notifications can be loaded.
isLoadingboolean"false"Show loading indicator at the bottom.
isLoadingboolean"false"Show loading indicator at the bottom.
triggerElementReactNodeCustom trigger element (replaces the default bell icon).
triggerElementReactNodeCustom trigger element (replaces the default bell icon).
emptyMessageReactNode"'No notifications'"Message shown when the list is empty.
emptyMessageReactNode"'No notifications'"Message shown when the list is empty.
headerReactNodeCustom header for the notification panel.
headerReactNodeCustom header for the notification panel.
footerReactNodeCustom footer for the notification panel.
footerReactNodeCustom footer for the notification panel.
widthstring"'380px'"Width of the notification panel.
widthstring"'380px'"Width of the notification panel.
maxHeightstring"'480px'"Maximum height of the scrollable list.
maxHeightstring"'480px'"Maximum height of the scrollable list.
itemTemplate(item: NotificationItem) => ReactNodeCustom render function for notification items.
itemTemplate(item: NotificationItem) => ReactNodeCustom render function for notification items.
classNamestringAdditional CSS class for the panel.
classNamestringAdditional CSS class for the panel.
NotificationItem Interface
idreqstringUnique identifier.
idreqstringUnique identifier.
titlereqstringNotification title.
titlereqstringNotification title.
descriptionstringNotification description text.
descriptionstringNotification description text.
timestampstring | DateWhen the notification occurred.
timestampstring | DateWhen the notification occurred.
iconReactNodeIcon displayed on the left.
iconReactNodeIcon displayed on the left.
readbooleanWhether the notification has been read.
readbooleanWhether the notification has been read.
categorystringCategory for tab filtering.
categorystringCategory for tab filtering.
actionReactNodeAction button or link for the notification.
actionReactNodeAction button or link for the notification.
dataRecord<string, unknown>Custom data attached to the notification.
dataRecord<string, unknown>Custom data attached to the notification.
Features
Unread Badge
Auto-computed unread count displayed as a badge on the trigger.
Category Tabs
Filter notifications by category with an auto-generated "All" tab.
Mark Read
Mark individual or all notifications as read with a single click.
Infinite Scroll
Load more notifications on scroll with onLoadMore callback.
Custom Trigger
Replace the default bell icon with any button or element.
Accessibility
ARIA dialog, haspopup, and keyboard navigation support.