Notification Center
NewCustomize
End
Count
Width380px
Max height440px
Accent
Installation
npx shadcn@latest add https://uibrik.com/r/notification-center.jsonInstall the packages
npm install @number-flow/react @tabler/icons-react motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/notification-center/notification-center.tsx"use client"; // A bell that opens every notification in one panel. The badge counts what's // unread; the panel lists everything, newest first, grouped into Today, // Yesterday and Earlier when the times are real dates. Opening one marks it // read; the cross that replaces its time on hover, or a swipe to the left on // touch, dismisses it, and the rows below slide up into the gap. // // Works controlled (`notifications` + `onNotificationsChange`) or on its own // (`defaultNotifications`). Arrow keys move between rows and Delete removes // one; Escape or a press outside closes the panel and hands focus back to the // bell. import NumberFlow from "@number-flow/react"; import { AnimatePresence, motion, useReducedMotion, type PanInfo } from "motion/react"; import { useCallback, useEffect, useRef, useState, useSyncExternalStore, type CSSProperties, type KeyboardEvent, type ReactNode,
Adds the files to
components/uibrik/notification-center and installs @number-flow/react, @tabler/icons-react and motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/notification-center.Usage
import { NotificationCenter } from "@/components/uibrik/notification-center/notification-center";<NotificationCenter align="end" badge="count" width={380} maxHeight={440} closeOnSelect={false} accent="" defaultNotifications={[]} label="Notifications" onSelect={(notification) => {}} // notifications={[…]} // onNotificationsChange={(list) => {}} // open={false} // onOpenChange={(open) => {}} // footer={<…/>}/>Props
NotificationCenter- align
- Type "start" | "center" | "end"
- "end"
- Which edge of the bell the panel lines up with.
- badge
- Type "count" | "dot"
- "count"
- Show how many are unread, or just that some are.
- width
- Type number
- 380
- Panel width. Never wider than the screen.
- maxHeight
- Type number
- 440
- Tallest the list grows before it scrolls.
- closeOnSelect
- Type boolean
- false
- Close the panel after a notification is opened.
- accent
- Type string
- ""
- Badge and unread-dot colour. Empty uses the text colour.
- notifications / onNotificationsChange
- Type Notification[] / (list) => void
- –
- Controlled list, newest first. Each is { id, title, time, name?, body?, read?, avatar?, icon? }.
- defaultNotifications
- Type Notification[]
- []
- Starting list when uncontrolled.
- onSelect
- Type (notification) => void
- –
- Called when a row is opened. It is marked read as well.
- open / onOpenChange
- Type boolean / (open) => void
- –
- Controlled open state.
- label
- Type string
- "Notifications"
- Panel heading and the bell's accessible name.
- footer
- Type ReactNode
- –
- Under the list, e.g. a link to a full inbox.
- className
- Type string
- –
- Classes for the bell button.