Notification Stack

Stacked notifications that spread into a list on hover or tap.

Preview

"use client";

import { RotateCw } from "lucide-react";
import {
  NotificationStack,
  type NotificationStackItem,
} from "@/components/motion/notification-stack";

const notifications: NotificationStackItem[] = [
  {
    id: "import-failed",
    title: "Orders import failed",
    description: "42s · TimeoutError at Step 2",
    trailing: (
      <span className="inline-flex items-center gap-1 text-amber-500 dark:text-amber-400">
        <RotateCw className="h-3.5 w-3.5" aria-hidden="true" />
        2
      </span>
    ),
  },
  {
    id: "sla-breach",
    title: "SLA breach",
    description: "2m 11s · Data enrichment",
  },
  {
    id: "sync-fixed",
    title: "Product sync auto-fixed",
    description: "5m · 404 on GET /products",
  },
];

export function NotificationStackPreview() {
  return (
    <div className="flex w-full items-center justify-center pt-52 pb-6">
      <NotificationStack items={notifications} />
    </div>
  );
}

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/notification-stack

API Reference

items
NotificationStackItem[]

Notifications to show, newest first. The first one sits on top.

Default—
expanded?
boolean

Whether the stack is fanned out, for controlled use.

Default—
defaultExpanded?
boolean

Whether the stack starts fanned out when uncontrolled. Default: false

Defaultfalse
onExpandedChange?
((expanded: boolean) => void)

Called with the new state when the stack expands or collapses.

Default—
onViewAll?
(() => void)

Called when the expanded stack is clicked, instead of collapsing it.

Default—
maxVisible?
number

Most cards shown in the stack, at least 1. Default: 3

Default3
collapsedLabel?
string

Footer text while collapsed. Default: "Notifications"

Default—
expandedLabel?
string

Footer text while expanded. Default: "View all"

Default—
emptyLabel?
string

Text shown when `items` is empty. Default: "All caught up"

Default—
labels?
Partial<{ collapsedLabel: string; expandedLabel: string; emptyLabel: string; collapsedAria: string; expandedAria: string; }>

Override any built-in string. `{count}` and `{label}` fill the stack's accessible names.

Default—
className?
string

Classes merged onto the root element.

Default—
classNames?
NotificationStackClassNames

Classes for inner parts: stack, card, content, title, description, trailing, footer, count.

Default—

Keep in mind

Some components on this site are inspired by or recreated from existing work across the web. I'm not here to take credit; just to learn, experiment, and sometimes push things a bit further. If something looks familiar and I forgot to mention you, reach out and I'll fix that right away.

Updated