Components

Notification Stack

A stacked notification card system with swipe-to-dismiss gestures, auto-pagination, action buttons, and animated transitions.

Client Only

Installation

pnpm dlx @docyrus/cli add @docyrus/ui-notification-stack
Required Packages(2 packages)
pnpm add motion @emotion/is-prop-valid

Usage

import {
  NotificationStack
} from '@docyrus/ui/components/notification-stack';
import type { NotificationItem } from '@docyrus/ui/components/notification-stack';

const notifications: NotificationItem[] = [
  {
    id: '1',
    type: 'success',
    title: 'Deployment complete',
    message: 'Your app has been deployed successfully.',
    actions: [{ label: 'View' }]
  },
  {
    id: '2',
    type: 'warning',
    title: 'Storage warning',
    message: 'You are using 90% of your storage quota.'
  },
  {
    id: '3',
    type: 'info',
    title: 'New feature',
    message: 'Dark mode is now available in settings.',
    variant: 'unread'
  }
];

<NotificationStack
  notifications={notifications}
  onDismiss={(id) => console.log('dismissed', id)}
  onClick={(id) => console.log('clicked', id)}
  onAction={(id, action) => console.log('action', id, action)}
/>

With Pagination & Load More

<NotificationStack
  notifications={notifications}
  maxVisible={5}
  loadMoreThreshold={2}
  onLoadMore={() => fetchMoreNotifications()}
  onDismiss={handleDismiss}
  emptyState={<p>No notifications</p>}
/>

Variants

VariantDescription
defaultStandard notification cards.
borderedCards with enhanced shadow (shadow-md).

Sizes

SizeDescription
smCompact padding and smaller text.
defaultStandard sizing.
lgLarger padding and text.

Components

ComponentDescription
NotificationStackMain container. Manages stacking, pagination, and dismissed state.
NotificationStackCardIndividual notification card with swipe-to-dismiss gesture.

API Reference

NotificationStack

PropTypeDefaultDescription
notificationsNotificationItem[]—Array of notification items to display.
maxVisiblenumber10Maximum number of visible cards before pagination.
loadMoreThresholdnumber2When remaining count reaches this threshold, onLoadMore is triggered.
onLoadMore() => void—Called when more notifications should be fetched.
onDismiss(id: string) => void—Called when a notification is swiped away.
onClick(id: string) => void—Called when a notification card is clicked.
onAction(id: string, action: string) => void—Called when an action button is clicked.
variant'default' | 'bordered''default'Visual style.
size'sm' | 'default' | 'lg''default'Card sizing.
emptyStateReactNode—Content shown when no notifications exist.
classNamestring—Additional CSS classes.

Type Reference

NotificationItem

FieldTypeDescription
idstringUnique identifier.
type'default' | 'success' | 'warning' | 'error' | 'info'Notification type (determines icon and color).
titlestringNotification title.
messagestringNotification body text.
iconReactNode | stringCustom icon override.
badgeReactNodeBadge content displayed alongside the notification.
actionsArray<{ label: string; onClick?: () => void }>Action buttons displayed at the bottom.
variant'default' | 'unread' | 'highlighted'Visual variant for the individual card.

Interaction Details

  • Swipe to dismiss: Drag horizontally past 100px or at 500px/s velocity.
  • Stacking: Cards stack with scale reduction (5% per level) and vertical offset (10px per level).
  • Pointer events: Only the top card is interactive; stacked cards below are visual-only.
  • Auto-dismiss on action: Cards are dismissed after an action button click.

On this page