Skip to content
synccn

Notification Center

New

Bell with unread count and a panel of notifications.

Installation

$ pnpm dlx shadcn@latest add @synccn/notification-center

First time in this project? Connect synccn with one command.

Usage

import { NotificationCenter } from "@/components/ui/notification-center";<NotificationCenter items={notifications} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

NotificationCenter

Bell button with an unread badge that opens a panel of notifications, with All/Unread tabs, mark-as-read on click and "Mark all as read". items: [{ id, title, body?, time, read?, icon?, avatar? }]

  • itemsrequired
    NotificationItem[]

    Initial notifications.

  • align
    "start" | "end"

    Default "end"

    Which edge of the bell the panel lines up with.

  • onOpenSettings
    () => void

    Shows a settings button that calls this.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

  • lib/utilscn (merges class names)
  • lib/hooksuseAutoSide (flips to the side with room), useClickOutside (closes on an outside click), useEscape (closes on Escape), usePresence (animates in and out)

npm packages

Accessibility

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: tab, tablist
  • ARIA attributes: aria-expanded, aria-label, aria-selected
  • Closes with Escape
  • Closes when you click or tap outside
  • Flips to whichever side has room, so it stays on screen