Notifications Panel

The NotificationsPanel is a customizable React component that provides a user interface for displaying and managing notifications within your application.

Features

  • View and manage unread and all notifications
  • Mark individual notifications or all notifications as read
  • Automatic notification updates at configurable intervals
  • Efficient handling of large notification lists through virtual scrolling
  • Fully customizable UI components
  • Flexible rendering modes (inline or overlay)
  • Responsive design with adjustable dimensions

Basic Integration Example

import * as React from "react";
import { NotificationsPanel, INotificationsPanelButtonComponentProps } from "@gooddata/sdk-ui-ext";
import { isAlertNotification } from "@gooddata/sdk-model";

// Import required styles
import "@gooddata/sdk-ui-ext/styles/scss/main.scss";

function NotificationsPanelButton({
    buttonRef,
    toggleNotificationPanel,
}: INotificationsPanelButtonComponentProps) {
    return (
        <button
            // Provide button ref, so notification panel can be properly positioned
            ref={buttonRef}
            onClick={toggleNotificationPanel}
        >
            Notifications
        </button>
    );
}

function Header() {
    return (
        <header>
            <nav>
                <NotificationsPanel
                    onNotificationClick={(notification) => {
                        if (isAlertNotification(notification)) {
                            const dashboardURL = notification.details.data.automation.dashboardURL;
                            window.open(dashboardURL);
                        }
                    }}
                    NotificationsPanelButton={NotificationsPanelButton}
                />
            </nav>
        </header>
    );
}

Props

NameTypeDefaultDescription
localeILocale“en-US”Specifies the locale for internationalization
backendIAnalyticalBackend-Backend instance. Falls back to BackendProvider context if not specified
workspacestring-Workspace ID. Falls back to WorkspaceProvider context if not specified
renderInlinebooleanfalseControls whether the panel renders inline or in an overlay
maxWidthnumber | string370Defines the maximum width of the notifications panel (overlay mode only)
maxListHeightnumber527Defines the maximum height of the notifications list (overlay mode only)
refreshIntervalnumber600000Time in milliseconds between notification refreshes. Set to 0 to disable
skeletonItemsCountnumber5Number of placeholder items shown during loading states
itemsPerPagenumber50Number of notifications loaded in each batch
itemHeightnumber52Height of individual notification items in pixels
itemsGapnumber10Vertical spacing between notification items in pixels
itemPaddingnumber15Horizontal padding of notification items in pixels
onNotificationClick(notification: INotification) => void-Callback fired when a notification is clicked
NotificationsPanelButtonReact.ComponentType-Button component to opens the notification panel. Required if renderInline is false.
NotificationsPanelReact.ComponentTypeDefaultNotificationsPanelCustom panel component
NotificationsPanelHeaderReact.ComponentTypeDefaultNotificationsPanelHeaderCustom panel header component
NotificationsListReact.ComponentTypeDefaultNotificationsListCustom notifications list component
NotificationsListEmptyStateReact.ComponentTypeDefaultNotificationsListEmptyStateCustom notification list empty state component
NotificationsListErrorStateReact.ComponentTypeDefaultNotificationsListErrorStateCustom notification list error state component
NotificationReact.ComponentTypeDefaultNotificationCustom notification component
NotificationSkeletonItemReact.ComponentTypeDefaultNotificationSkeletonItemCustom notification skeleton item component

Customization Props

The NotificationsPanel component provides comprehensive customization options through its props. For applications requiring specific design requirements beyond the default styling, these customization props allow you to fully adapt the panel’s appearance and behavior.

Important: We strongly recommend using the provided customization props and custom components for styling modifications rather than direct CSS class overrides, which may break in future updates.

The following components can be customized by providing your own implementations:

  • NotificationsPanelButton
  • NotificationsPanel
  • NotificationsPanelHeader
  • NotificationsList
  • NotificationsListEmptyState
  • NotificationsListErrorState
  • Notification
  • NotificationSkeletonItem

Component Hierarchy

The components are organized in the following hierarchy:

NotificationsPanel
├── NotificationsPanelButton (when not inline)
└── NotificationsPanel
    ├── NotificationsPanelHeader
    └── NotificationsList
        ├── NotificationsListEmptyState (when empty)
        ├── NotificationsListErrorState (when error)
        ├── NotificationSkeletonItem (when loading)
        └── Notification (for each notification)

Each component can be customized independently while maintaining the overall functionality of the notifications panel. When customizing components, make sure to implement all the required props to ensure proper functionality.

Example with Custom Components and Inline Rendering

import * as React from "react";
import { NotificationsPanel } from "@gooddata/sdk-ui-ext";
import { CustomHeader, CustomNotification } from "./components";

// Import required styles
import "@gooddata/sdk-ui-ext/styles/scss/main.scss";

function MyComponent() {
    return (
        <div
            // Inline rendering adjusts dimensions according to parent container
            style={{ width: 400, height: 500 }}
        >
            <NotificationsPanel
                NotificationsPanelHeader={CustomHeader}
                Notification={CustomNotification}
                renderInline
                refreshInterval={300000}
                onNotificationClick={(notification) => {
                    console.log("Notification clicked:", notification);
                }}
            />
        </div>
    );
}

Customizable Components

NotificationsPanelButton

The button component that opens the notifications panel. Required and rendered only when renderInline is false.

Props

NameTypeDescription
buttonRefRefObjectReference to the button element for panel alignment
openNotificationPanel() => voidFunction to open the panel
closeNotificationPanel() => voidFunction to close the panel
toggleNotificationPanel() => voidFunction to toggle the panel
isNotificationPanelOpenbooleanWhether the panel is currently open
hasUnreadNotificationsbooleanWhether there are unread notifications

NotificationsPanelHeader

The header component of the notifications panel. In the default implementation, it displays “all” / “unread” tabs and mark all as read button.

Props

NameTypeDescription
activeViewINotificationsPanelViewCurrent view mode (‘all’ or ‘unread’)
changeActiveView(view: INotificationsPanelView) => voidFunction to change the view mode
hasUnreadNotificationsbooleanWhether there are unread notifications
unreadNotificationsCountnumberNumber of unread notifications
markAllNotificationsAsRead() => voidFunction to mark all notifications as read

NotificationsList

The main list component that displays notifications, empty state, or error component.

Props

NameTypeDescription
NotificationsListEmptyStateReact.ComponentTypeComponent to render when list is empty
NotificationsListErrorStateReact.ComponentTypeComponent to render when there’s an error
NotificationReact.ComponentTypeComponent to render individual notifications
NotificationSkeletonItemReact.ComponentTypeComponent to render loading skeleton
activeViewINotificationsPanelViewCurrent view mode
statusUseCancelablePromiseStatusLoading status
errorGoodDataSdkErrorError object if loading failed
activeNotificationsINotification[]Array of notifications to display
markNotificationAsRead(notificationId: string) => PromiseFunction to mark a notification as read
onNotificationClick(notification: INotification) => voidFunction to handle notification clicks
hasNextPagebooleanWhether there are more notifications to load
loadNextPage() => voidFunction to load next page of notifications
itemHeightnumberHeight of each notification item
itemsGapnumberGap between notification items
itemPaddingnumberPadding of notification items
skeletonItemsCountnumberNumber of skeleton items to show while loading
maxListHeightnumberMaximum height of the list

NotificationsListEmptyState

Component displayed when there are no notifications.

Props

NameTypeDescription
activeViewINotificationsPanelViewCurrent view mode (‘all’ or ‘unread’)

NotificationsListErrorState

Component displayed when there’s an error loading notifications.

Props

NameTypeDescription
errorGoodDataSdkErrorError object containing details about what went wrong

Notification

Component for rendering individual notification items.

Props

NameTypeDescription
notificationINotificationThe notification data to display
markNotificationAsRead(id: string) => voidFunction to mark the notification as read
onNotificationClick(notification: INotification) => voidFunction to handle notification clicks

NotificationSkeletonItem

Component for rendering loading placeholder items.

Props

NameTypeDescription
itemHeightnumberHeight of the skeleton item in pixels