Notification Center
NotificationCenter is a bell with an unread count. It opens a panel of notifications grouped by day: a Popover on desktop, a bottom sheet on mobile.
Import
Install from npm, copy the source into your project with @yugen-ui/cli or the shadcn CLI, or import directly when working in this repo.
// npm install yugen-uiimport { NotificationCenter, useNotifications, type NotificationItem } from "yugen-ui";Variants
Each tile is a standalone example: hover to copy, or press Code to see the source.
Loading & error
The skeleton only shows when the wait is longer than 300ms; the error state has a Retry button when onRetry is passed.
Usage
- Write titles that say who did what; put the details in body.
- Make a notification clickable so it leads to the right place and marks itself as read.
- Use the warning / error intents only for things people need to act on.
- Don't use NotificationCenter for immediate feedback on an action. Use Toast.
- Don't count read notifications on the bell.
- Don't compute the current time during server render. Pass now, or let the component read it after mount.
Props
| Prop · Type | Default | Description |
|---|---|---|
| itemsNotificationItem[] | Default: — | { id, title, body?, time, read?, author?, icon?, intent?, href? }. |
| onMarkRead / onMarkAllRead / onDismiss(id) => void / () => void / (id) => void | Default: — | Actions (controlled). |
| onItemClick(item) => void | Default: — | Click on a notification; also calls onMarkRead if it is unread. |
| loading / error / onRetryboolean / ReactNode / () => void | Default: — | Loading and error states. |
| nowDate | number | Default: — | Fixed reference time (SSR, tests). |
| open / defaultOpen / onOpenChangeboolean | Default: — | Panel open state. |
| mode / breakpoint"auto" | "popover" | "sheet" / "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | number | Default: "auto" / "3xl" | Popover or bottom sheet; breakpoint takes the same tokens as Sheet (a px number is deprecated, removed in 1.0). |
| title / footer / announcestring / ReactNode / boolean | Default: "Notifications" / — / true | Title, panel footer, announcing new notifications. |
| useNotifications | Default: — | Small store for demos; spread bind into NotificationCenter. |
Messages
Text built into the component: labels, aria-labels, screen reader announcements.
English by default. Change it with the messages prop of YugenProvider, by the namespace below; messagesVi has the Vietnamese set. See Interface language.
messages.notificationCenter
| Key · Type | Default (English) | messagesVi |
|---|---|---|
| titlestring Tiêu đề bảng, tên nút chuông và tên danh sách (khi không truyền | Default (English)"Notifications" | messagesVi"Thông báo" |
| triggerUnread(title: string, unread: number) => string Tên nút chuông khi còn thông báo chưa đọc. | Default (English)(title, unread) => `${title}, ${unread} unread` | messagesVi(title, unread) => `${title}, ${unread} chưa đọc` |
| closestring Nhãn nút đóng bottom sheet. | Default (English)"Close" | messagesVi"Đóng" |
| markAllReadstring | Default (English)"Mark all as read" | messagesVi"Đánh dấu tất cả đã đọc" |
| filterstring Tên nhóm tab lọc. | Default (English)"Filter notifications" | messagesVi"Lọc thông báo" |
| allstring | Default (English)"All" | messagesVi"Tất cả" |
| unreadstring Tab "chưa đọc" (số lượng được nối thêm phía sau). | Default (English)"Unread" | messagesVi"Chưa đọc" |
| loadErrorstring Tiêu đề ErrorState khi tải lỗi. | Default (English)"Couldn't load notifications" | messagesVi"Không tải được thông báo" |
| emptyTitlestring | Default (English)"No notifications yet" | messagesVi"Chưa có thông báo" |
| emptyDescriptionstring | Default (English)"New notifications will appear here." | messagesVi"Thông báo mới sẽ xuất hiện ở đây." |
| emptyUnreadTitlestring | Default (English)"You're all caught up" | messagesVi"Bạn đã đọc hết" |
| emptyUnreadDescriptionstring | Default (English)"No unread notifications." | messagesVi"Không còn thông báo chưa đọc." |
| unreadSuffixstring Chữ ẩn nối sau tiêu đề mục chưa đọc, cho trình đọc màn hình. | Default (English)", unread" | messagesVi", chưa đọc" |
| markReadstring Tooltip nút đánh dấu đã đọc. | Default (English)"Mark as read" | messagesVi"Đánh dấu đã đọc" |
| markReadItem(title: string) => string Tên nút đánh dấu đã đọc của một mục. | Default (English)(title) => `Mark as read: ${title}` | messagesVi(title) => `Đánh dấu đã đọc: ${title}` |
| dismissstring Tooltip nút bỏ thông báo. | Default (English)"Dismiss" | messagesVi"Bỏ thông báo" |
| dismissItem(title: string) => string Tên nút bỏ thông báo của một mục. | Default (English)(title) => `Dismiss: ${title}` | messagesVi(title) => `Bỏ thông báo: ${title}` |
| announceOne(title: string) => string Đọc qua live region khi có một thông báo mới. | Default (English)(title) => `New notification: ${title}` | messagesVi(title) => `Thông báo mới: ${title}` |
| announceMany(count: number) => string Đọc qua live region khi có nhiều thông báo mới. | Default (English)(count) => (count === 1 ? "1 new notification" : `${count} new notifications`) | messagesVi(count) => `${count} thông báo mới` |
| justNowstring | Default (English)"Just now" | messagesVi"Vừa xong" |
| minutesAgo(minutes: number) => string | Default (English)(minutes) => (minutes === 1 ? "1 minute ago" : `${minutes} minutes ago`) | messagesVi(minutes) => `${minutes} phút trước` |
| hoursAgo(hours: number) => string | Default (English)(hours) => (hours === 1 ? "1 hour ago" : `${hours} hours ago`) | messagesVi(hours) => `${hours} giờ trước` |
| todaystring | Default (English)"Today" | messagesVi"Hôm nay" |
| yesterdaystring | Default (English)"Yesterday" | messagesVi"Hôm qua" |