Skip to content

Notification Center for React

A React notification center: a bell with a live unread count that opens a glass inbox with tabs, day groups and inline actions.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/notification-center.json
  • NotificationCenter
  • NotificationPanel
  • defaultNotificationLabels
  • defaultNotificationCenterLabels
  • +2 more

Bell and inbox

Open the bell, then try “Simulate a notification”: the bell rings, the count pops and the new row glows once. Hover a row for its actions, accept the invite, or press Delete on a focused row (Undo or ⌘Z / Ctrl+Z brings it back). On a phone the inbox opens as a sheet from the bottom of the screen.

Acme

Files to copy

13 folders · 16 files · 4 packages
From theme/src/
  • blocks/notification-center.tsx
  • components/avatar/
  • components/button/
  • components/empty-state/
  • components/kbd/
  • components/spinner/
  • components/tabs/
  • components/tooltip/
  • blocks/notification-center/
  • hooks/{use-controllable.ts, use-direction.ts, use-latest.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts}
  • motion/{gate.ts, tokens.ts}
  • lib/{cn.ts, form.ts, heading.ts, initials.ts, popup-motion.ts, state-light.tsx, warn-once.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/notification-center.jsonRegistry item: notification-center. The styles need the Tailwind v4 glass UI setup.
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Inline panel

NotificationPanel is the same inbox without the bell, as a glass card for a notifications page, a drawer or a dashboard column. Add your own header controls next to “Mark all as read”.

Any language

Every string is a label, and day headings and times come from Intl for the locale: Heute, Gestern, then weekdays. Mark everything read on the Ungelesen tab to reach the empty state.

NotificationCenter

PropTypeDefaultDescription
notificationsNotificationItem[]NoneThe notifications to show, when you control the list yourself (pair it with the change callbacks).
defaultNotificationsNotificationItem[]NoneSets the starting list when uncontrolled.
onNotificationsChange((next: NotificationItem[]) => void)NoneCalled with the whole new list after any change (read, unread, dismiss, undo).
onSelect((item: NotificationItem) => void)NoneCalled when a notification is opened (it is marked as read first).
onDismiss((item: NotificationItem) => void)NoneCalled as soon as a notification is dismissed (button, Delete key or swipe). Undo can still bring it back: see onRestore.
onRestore((item: NotificationItem) => void)NoneCalled when Undo brings a dismissed notification back.
onDismissCommit((item: NotificationItem) => void)NoneCalled once a dismissal can no longer be undone: the undo bar timed out, another notification was dismissed, or the inbox closed. Delete it on your server here.
viewAllHrefstringNoneShows a "View all notifications" link at the bottom.
headerActionsReactNodeNoneExtra controls in the header, after "Mark all as read" (e.g. a settings link).
defaultTabNotificationTab"all"The tab that is selected when the panel first renders.
nowDatethe real clock, refreshed every 30 secondsThe current time for "5m ago" and the day groups. On a prerendered or server-rendered page pass a fixed date, so the HTML matches what the browser renders when it hydrates.
localestringthe browser'sSets the BCP 47 locale for day headings and times.
labelsPartial<NotificationCenterLabels>defaultNotificationCenterLabelsEvery other string, for translation: labels={{ trigger: "…" }}; omitted keys keep the English of defaultNotificationCenterLabels. All 30 keys of NotificationCenterLabels are listed in the key table under the props table.
headingLevelHeadingLevelOption2Heading level of the panel title (2 | 3 | 4, default 2); day groups sit one level below. "none" renders paragraphs with no heading role (for an example).
openbooleanNoneWhether the panel is open (controlled).
defaultOpenbooleanfalseWhether the panel is open at first when open is not controlled (boolean, default false).
onOpenChange((open: boolean) => void)NoneCalled when the panel opens or closes.
side"top" | "bottom" | "left" | "right""bottom"Which side of the bell the panel opens on ("top" | "bottom" | "left" | "right", default "bottom").
align"center" | "end" | "start""end"Sets the alignment against the bell ("start" | "center" | "end", default "end").
maxnumber99Counts above this show as "99+" (number, default 99).
classNamestringNoneClasses for the bell button (the outer element; the panel is portaled).
panelClassNamestringNoneAdds extra classes to the glass panel.
NotificationCenterLabels keys and English defaults (30)
Pass any key in labels; the rest keep the defaults of defaultNotificationCenterLabels.
KeyEnglish default
trigger(n) => (n > 0 ? `Notifications, ${n} unread` : "Notifications")
titleNotifications
markAllReadMark all as read
closeClose notifications
tabsFilter notifications
allAll
unreadUnread
mentionsMentions
todayToday
yesterdayYesterday
undatedUndated
justNowJust now
unreadStateunread
markReadMark as read
markUnreadMark as unread
dismissDismiss
swipeDismissDismiss
dismissedNotification dismissed
undoUndo
viewAllView all notifications
emptyAllTitleNo notifications yet
emptyAllDescriptionWhen teammates mention you, comment or invite you, it shows up here.
emptyUnreadTitleYou're all caught up
emptyUnreadDescriptionNothing new since you last looked. Enjoy the quiet.
emptyMentionsTitleNo mentions
emptyMentionsDescriptionWhen someone @mentions you, you'll find it here.
announceNew(n) => (n === 1 ? "1 new notification" : `${n} new notifications`)
announceAllReadAll notifications marked as read
announceDismissed(shortcut) => `Notification dismissed. Press ${shortcut} to undo.`
announceRestoredNotification restored

NotificationItem

PropTypeDefaultDescription
idstringNoneStable identifier of the notification, used as the React key and in callbacks.
titleReactNodeNoneThe sentence; wrap names in <b>. Also the row’s accessible name.
timeDate | string | numberNoneWhen it happened. An unreadable value never breaks the inbox: the item is listed last, under “Undated”.
actor{ name, avatar? }NoneShown as an avatar (initials without an image). Leave out for system notices.
kind"mention" | "comment" | "reaction" | "invite" | "assign" | "system" | "success" | "warning"NoneBadge on the avatar, or the icon of a system notice.
descriptionReactNodeNoneA quote or detail, clamped to two lines.
readbooleanfalseRead rows lose the dot and tint.
mentionbooleankind === "mention"Lists the notification under the Mentions tab.
hrefstringNoneOpening the row follows this link.
actionsReactNodeNoneButtons under the text (Accept / Decline …).

NotificationPanel

PropTypeDefaultDescription
notificationsNotificationItem[]NoneThe notifications to show, when you control the list yourself (pair it with the change callbacks).
defaultNotificationsNotificationItem[]NoneSets the starting list when uncontrolled.
onNotificationsChange((next: NotificationItem[]) => void)NoneCalled with the whole new list after any change (read, unread, dismiss, undo).
onSelect((item: NotificationItem) => void)NoneCalled when a notification is opened (it is marked as read first).
onDismiss((item: NotificationItem) => void)NoneCalled as soon as a notification is dismissed (button, Delete key or swipe). Undo can still bring it back: see onRestore.
onRestore((item: NotificationItem) => void)NoneCalled when Undo brings a dismissed notification back.
onDismissCommit((item: NotificationItem) => void)NoneCalled once a dismissal can no longer be undone: the undo bar timed out, another notification was dismissed, or the inbox closed. Delete it on your server here.
viewAllHrefstringNoneShows a "View all notifications" link at the bottom.
headerActionsReactNodeNoneExtra controls in the header, after "Mark all as read" (e.g. a settings link).
defaultTabNotificationTab"all"The tab that is selected when the panel first renders.
nowDatethe real clock, refreshed every 30 secondsThe current time for "5m ago" and the day groups. On a prerendered or server-rendered page pass a fixed date, so the HTML matches what the browser renders when it hydrates.
localestringthe browser'sSets the BCP 47 locale for day headings and times.
labelsPartial<NotificationCenterLabels>defaultNotificationCenterLabelsEvery other string, for translation: labels={{ trigger: "…" }}; omitted keys keep the English of defaultNotificationCenterLabels. All 30 keys of NotificationCenterLabels are listed in the key table under the props table.
headingLevelHeadingLevelOption2Heading level of the panel title (2 | 3 | 4, default 2); day groups sit one level below. "none" renders paragraphs with no heading role (for an example).
classNamestring32remClasses for the glass card (set its height here; it defaults to 32rem).

Keyboard

KeysAction
Enter/Spaceon the bellOpen the panel.
EscapeClose the panel and return focus to the bell.
TabEnter the tabs, then the list.
↑/↓Previous / next notification.
Home/EndFirst / last notification.
EnterOpen the notification (it is marked read first).
DeleteDismiss it; focus moves on.
Ctrl/Cmd + ZUndo the dismissal.

Accessibility

  • The bell is named “Notifications, 3 unread” and the count is text; the panel is a labeled popover.
  • Dismissals (with the undo shortcut), arrivals and “all read” are announced politely.
  • Swipe-to-dismiss on touch always has the dismiss button as an alternative.

All exports on this page

  • NotificationCenter — Props (see NotificationCenterProps): the shared inbox props (notifications / defaultNotifications / onNotificationsChange, onSelect, onDismiss, onRestore, onDismissCommit, viewAllHref, headerActions, defaultTab ("all"), now, locale, labels, headingLevel (2)) plus open / defaultOpen (false) / onOpenChange, side ("bottom"), align ("end"), max (99), className (the bell) and panelClassName.
  • NotificationPanel — The inbox as an inline glass card (no bell): for a page, a drawer or a dashboard column.
  • defaultNotificationCenterLabels — The English NotificationCenterLabels used when labels is omitted; a partial labels prop is merged over them.
  • defaultNotificationLabels — The former name of defaultNotificationCenterLabels, kept as an alias for one release.

When to use the notification center

  • Use NotificationCenter as a notification dropdown for the bell in an app header, where an unread count badge opens a popover inbox with All, Unread and Mentions tabs and, with viewAllHref, a link to view everything.
  • Use NotificationPanel for a dashboard column or a drawer that shows the inbox inline, giving it a height with className because it defaults to 32rem.
  • Use it when dismissals need a safety net, since Delete removes a notification, an undo bar appears, and Ctrl or Cmd plus Z restores it.
  • Skip it when you only need a brief confirmation such as "Saved"; a Toast fits transient messages better than a persistent inbox with read state and tabs.
  • Pair it with Avatar for sender images, Tooltip for the header actions, and KbdShortcut to teach the undo shortcut, passing items through notifications or defaultNotifications.

Frequently asked questions

20 blocks pages in all: browse them on All blocks.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .