Push Components

3 Components

Pre-built, customizable push notification components. Drop-in UI for permission prompts, notification bells, and notification lists.

Quick Start

All push components are available from the SDK. Wrap your app with SylphxProvider for automatic push notification context.
Installation
import {
  PushPrompt,
  NotificationBell,
  NotificationList,
} from '@sylphx/platform-sdk/react'

PushPrompt

A customizable permission prompt that asks users to enable push notifications. Handles browser permission state automatically and provides callbacks for all user actions.

Accessible
Themeable
Basic Usage
import { PushPrompt } from '@sylphx/platform-sdk/react'

export default function App() {
  return (
    <PushPrompt
      onAllow={() => {
        console.log('User allowed notifications')
      }}
      onDeny={() => {
        console.log('User denied notifications')
      }}
      onDismiss={() => {
        console.log('User dismissed the prompt')
      }}
    />
  )
}

Props

PropertyTypeDescription
onAllow() => voidCallback fired when user allows notifications
onDeny() => voidCallback fired when user denies notifications
onDismiss() => voidCallback fired when user dismisses the prompt
onError(error: Error) => voidCallback fired on permission request error
titlestring= "Enable Notifications"Prompt title text
descriptionstring= "Stay updated with important alerts"Prompt description text
allowLabelstring= "Enable"Allow button label
denyLabelstring= "Not now"Deny button label
iconReactNodeCustom icon to display
showDenyButtonboolean= trueShow the deny button
showCloseButtonboolean= trueShow close button to dismiss
position"top" | "bottom" | "center"= "bottom"Prompt position on screen
variant"banner" | "modal" | "inline"= "banner"Visual style variant
delaynumber= 3000Delay before showing (ms)
hideWhenGrantedboolean= trueAuto-hide when permission granted
hideWhenDeniedboolean= trueAuto-hide when permission denied
persistDismissalboolean= trueRemember dismissal in localStorage
dismissalDaysnumber= 7Days to remember dismissal
themeThemeVariablesCustom theme overrides
classNamestringAdditional CSS classes

Advanced Examples

<PushPrompt
  title="Never miss an update"
  description="Get notified when your order ships, when prices drop, or when new products arrive."
  allowLabel="Yes, notify me"
  denyLabel="Maybe later"
  icon={<BellRing className="w-8 h-8 text-primary" />}
/>

Permission States

The prompt automatically handles browser permission states. It won't show if notifications are already granted or if the browser has previously denied permission.

NotificationBell

A bell icon component with an unread notification count badge. Clicking opens a dropdown or navigates to a notifications page. Perfect for headers and navigation bars.

Live Count
Dropdown
Basic Usage
import { NotificationBell } from '@sylphx/platform-sdk/react'

export function Header() {
  return (
    <header className="flex items-center justify-between p-4">
      <Logo />
      <nav className="flex items-center gap-4">
        <NotificationBell
          onClick={() => {
            console.log('Bell clicked')
          }}
        />
        <UserMenu />
      </nav>
    </header>
  )
}

Props

PropertyTypeDescription
countnumberNumber of unread notifications (auto-fetched if not provided)
maxCountnumber= 99Max count to display before showing +
onClick() => voidCallback when bell is clicked
hrefstringLink to notifications page (alternative to onClick)
showDropdownboolean= falseShow dropdown on click
dropdownWidthnumber= 320Dropdown width in pixels
dropdownMaxHeightnumber= 400Dropdown max height in pixels
showBadgeboolean= trueShow the count badge
badgePosition"top-right" | "top-left"= "top-right"Badge position
animatedboolean= trueAnimate bell on new notifications
pulseOnNewboolean= truePulse animation for new notifications
size"sm" | "md" | "lg"= "md"Bell icon size
iconReactNodeCustom bell icon
emptyIconReactNodeIcon when no notifications
pollIntervalnumber= 30000Interval to poll for new notifications (ms)
onNewNotification(notification: Notification) => voidCallback when new notification arrives
themeThemeVariablesCustom theme overrides
classNamestringAdditional CSS classes

Advanced Examples

<NotificationBell
  showDropdown={true}
  dropdownWidth={360}
  dropdownMaxHeight={500}
  onNewNotification={(notification) => {
    // Play sound or show toast
    playNotificationSound()
  }}
/>

Real-time Updates

For instant notification updates, connect to WebSocket or use Server-Sent Events. The pollInterval prop is a fallback for simpler setups.

NotificationList

A full-featured notification list with support for actions, grouping, filtering, and bulk operations. Use in a dedicated notifications page or as dropdown content.

Mark as Read
Delete
Actions
Basic Usage
import { NotificationList } from '@sylphx/platform-sdk/react'

export default function NotificationsPage() {
  return (
    <div className="max-w-2xl mx-auto py-8">
      <h1 className="text-2xl font-bold mb-6">Notifications</h1>
      <NotificationList
        onNotificationClick={(notification) => {
          // Navigate to related content
          if (notification.data?.url) {
            router.push(notification.data.url)
          }
        }}
        onMarkAsRead={(id) => {
          console.log('Marked as read:', id)
        }}
        onDelete={(id) => {
          console.log('Deleted:', id)
        }}
      />
    </div>
  )
}

Props

PropertyTypeDescription
notificationsNotification[]Array of notifications (auto-fetched if not provided)
onNotificationClick(notification: Notification) => voidCallback when a notification is clicked
onMarkAsRead(id: string) => voidCallback when marking a notification as read
onMarkAllAsRead() => voidCallback when marking all as read
onDelete(id: string) => voidCallback when deleting a notification
onDeleteAll() => voidCallback when deleting all notifications
onAction(notification: Notification, action: string) => voidCallback for custom notification actions
showMarkAllAsReadboolean= trueShow "Mark all as read" button
showDeleteAllboolean= falseShow "Delete all" button
showFiltersboolean= trueShow filter tabs (all/unread)
showGroupingboolean= trueGroup notifications by date
showTimestampsboolean= trueShow relative timestamps
showActionsboolean= trueShow action buttons on notifications
emptyStateReactNodeCustom empty state content
emptyStateTitlestring= "No notifications"Empty state title
emptyStateDescriptionstring= "You're all caught up!"Empty state description
loadingStateReactNodeCustom loading state
pageSizenumber= 20Number of notifications per page
infiniteScrollboolean= trueEnable infinite scroll loading
variant"default" | "compact" | "detailed"= "default"Visual density variant
themeThemeVariablesCustom theme overrides
classNamestringAdditional CSS classes

Notification Object

PropertyTypeDescription
idrequiredstringUnique notification ID
titlerequiredstringNotification title
bodyrequiredstringNotification body text
iconstringIcon URL or component name
imagestringLarge image URL
readboolean= falseWhether notification has been read
createdAtrequiredDateWhen the notification was created
categorystringNotification category for grouping
actionsNotificationAction[]Available actions for this notification
dataRecord<string, unknown>Custom data attached to notification

Advanced Examples

<NotificationList
  showMarkAllAsRead={true}
  showDeleteAll={true}
  showFilters={true}
  showGrouping={true}
  infiniteScroll={true}
  pageSize={25}
  onNotificationClick={(notification) => {
    // Mark as read and navigate
    markAsRead(notification.id)
    if (notification.data?.url) {
      router.push(notification.data.url)
    }
  }}
  onAction={(notification, action) => {
    switch (action) {
      case 'view-order':
        router.push(`/orders/${notification.data.orderId}`)
        break
      case 'dismiss':
        deleteNotification(notification.id)
        break
    }
  }}
/>

Performance

For large notification lists, enable infiniteScroll and set an appropriate pageSize to avoid loading all notifications at once.

Theming

All push components support theming via the theme prop. Customize colors, fonts, and border radius to match your brand.

Custom Theme
import { NotificationBell, NotificationList, defaultTheme, type ThemeVariables } from '@sylphx/platform-sdk/react'

const customTheme: ThemeVariables = {
  ...defaultTheme,
  colorPrimary: '#8b5cf6',
  colorPrimaryHover: '#7c3aed',
  colorBackground: '#ffffff',
  colorForeground: '#1f2937',
  colorMuted: '#f3f4f6',
  colorMutedForeground: '#6b7280',
  colorBorder: '#e5e7eb',
  colorBadge: '#ef4444',
  colorBadgeForeground: '#ffffff',
  fontFamily: 'Inter, sans-serif',
  fontSize: '14px',
  borderRadius: '0.75rem',
}

<NotificationBell theme={customTheme} />
<NotificationList theme={customTheme} />
PropertyTypeDescription
colorPrimarystring= #000000Primary brand color
colorPrimaryHoverstring= #1f2937Primary color on hover
colorBackgroundstring= #ffffffComponent background
colorForegroundstring= #1f2937Primary text color
colorMutedstring= #f3f4f6Muted background
colorMutedForegroundstring= #6b7280Secondary text color
colorBorderstring= #e5e7ebBorder color
colorBadgestring= #ef4444Badge background color
colorBadgeForegroundstring= #ffffffBadge text color
fontFamilystring= system-uiFont family
borderRadiusstring= 0.5remBorder radius

Best Practices

Ask at the Right Time

Don't show the push prompt immediately. Wait for users to engage with your app first.

Explain the Value

Clearly communicate what notifications users will receive and why they're valuable.

Respect Dismissal

Use persistDismissal to avoid repeatedly asking users who have declined.

Keep Notifications Actionable

Include clear actions in notifications so users know what to do next.

Need more customization?

Use the push notification hooks for fully custom UI while keeping all the functionality.