Command Palette

Search for a command to run...

Docs
Notifications Popover

Notifications Popover

A dropdown menu component for displaying notifications with different types and read states.

Loading...

Installation

Props

PropTypeDefaultDescription
notificationsNotification[]defaultNotificationsArray of notification objects
iconReact.ReactNodeundefinedCustom icon for the trigger button
maxHeightstring"64"Maximum height of dropdown content

Notification Interface

interface Notification {
  id: number;
  type: "message" | "alert" | "success";
  message: string;
  timestamp?: string;
  read?: boolean;
}

Features

  • Notification Types: Support for message, alert, and success notifications
  • Read States: Visual distinction between read and unread notifications
  • Unread Count: Badge showing number of unread notifications
  • Type Icons: Different icons for each notification type
  • Timestamps: Optional timestamp display for each notification
  • Scrollable Content: Handles large numbers of notifications with scrolling

Usage

import NotificationsPopover, {
  Notification,
} from "@/components/ui/notifications-popover";
 
export default function Example() {
  const notifications: Notification[] = [
    {
      id: 1,
      type: "message",
      message: "New message from Alice",
      timestamp: "Just now",
    },
    {
      id: 2,
      type: "alert",
      message: "Server backup failed",
      timestamp: "5m ago",
    },
    {
      id: 3,
      type: "success",
      message: "Database restored successfully",
      timestamp: "10m ago",
      read: true,
    },
  ];
 
  return (
    <div className="p-6">
      <NotificationsPopover notifications={notifications} maxHeight="80" />
    </div>
  );
}