---
title: "Notification Stack"
description: "Compact notification cards that spring from a stacked summary into a readable list on hover, focus or tap."
category: "Blocks"
publishedAt: "2026-07-14"
updatedAt: "2026-11-24"
documentation: "https://beui.dev/components/blocks/notification-stack"
markdown: "https://beui.dev/components/blocks/notification-stack.md"
license: "MIT"
---

# Notification Stack

> Compact notification cards that spring from a stacked summary into a readable list on hover, focus or tap.

## Install

```bash
npx shadcn@latest add @beui/notification-stack
```

## Dependencies

- `clsx`
- `lucide-react`
- `motion`
- `react`
- `tailwind-merge`

## Usage

```tsx
"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>
  );
}
```

## API Reference

### NotificationStack

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `items` | `NotificationStackItem[]` | — | Yes | Notifications to show, newest first. The first one sits on top. |
| `expanded` | `boolean` | — | No | Whether the stack is fanned out, for controlled use. |
| `defaultExpanded` | `boolean` | `false` | No | Whether the stack starts fanned out when uncontrolled. Default: false |
| `onExpandedChange` | `((expanded: boolean) => void)` | — | No | Called with the new state when the stack expands or collapses. |
| `onViewAll` | `(() => void)` | — | No | Called when the expanded stack is clicked, instead of collapsing it. |
| `maxVisible` | `number` | `3` | No | Most cards shown in the stack, at least 1. Default: 3 |
| `collapsedLabel` | `string` | — | No | Footer text while collapsed. Default: "Notifications" |
| `expandedLabel` | `string` | — | No | Footer text while expanded. Default: "View all" |
| `emptyLabel` | `string` | — | No | Text shown when `items` is empty. Default: "All caught up" |
| `labels` | `Partial<{ collapsedLabel: string; expandedLabel: string; emptyLabel: string; collapsedAria: string; expandedAria: string; }>` | — | No | Override any built-in string. `{count}` and `{label}` fill the stack's accessible names. |
| `className` | `string` | — | No | Classes merged onto the root element. |
| `classNames` | `NotificationStackClassNames` | — | No | Classes for inner parts: stack, card, content, title, description, trailing, footer, count. |

## Types

### NotificationStackItem

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | Unique key for the notification. |
| `title` | `ReactNode` | Yes | Heading text on the card. |
| `description` | `ReactNode` | No | Smaller text under the title. Omitted when not set. |
| `trailing` | `ReactNode` | No | Content at the card's top right, such as a timestamp. |

### NotificationStackClassNames

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `stack` | `string` | No | Classes for the grid that holds the cards. |
| `card` | `string` | No | Classes for each notification card. |
| `content` | `string` | No | Classes for the text column inside each card. |
| `title` | `string` | No | Classes for each card's title. |
| `description` | `string` | No | Classes for each card's description. |
| `trailing` | `string` | No | Classes for each card's trailing content. |
| `footer` | `string` | No | Classes for the row under the cards with the count and label. |
| `count` | `string` | No | Classes for the round badge showing the notification count. |

## About Notification Stack

Notification Stack is a React notification summary built with Framer Motion where cards sit stacked behind one another and spring apart into a readable list on hover, focus or tap. Collapsed, only the newest card is shown with the others peeking out beneath it, and a footer shows the count and a label that rolls to "View all" when the list opens. A second activation calls your view-all handler, and an empty state shows when there are no items.

### When to use it

- A dashboard header or sidebar needs a compact preview of recent notifications that expands on demand.
- A home screen or widget wants to show the latest alerts, messages or activity without a full notification center.
- A mobile layout needs a tap-to-expand summary that leads to a full notifications page.

### Accessibility

The whole stack is a single button with aria-expanded and an accessible name that states the notification count and the next action. Keyboard focus expands it, Escape collapses it while keeping focus in place, and tabbing away collapses it. On touch, the first tap expands the stack and a tap outside collapses it. With reduced motion enabled, the cards and footer move between states instantly.

### FAQ

**How do I make a stacked notification card list in React?**

Install the block and pass items to NotificationStack, each with an id, a title and optionally a description and trailing content. maxVisible sets how many cards appear in the stack.

**Can I control whether the stack is expanded?**

Yes. Pass expanded with onExpandedChange for controlled use, or defaultExpanded for uncontrolled use.

**How do I link to a full notifications page?**

Pass onViewAll. When the stack is already expanded, activating it calls onViewAll. collapsedLabel, expandedLabel and emptyLabel change the footer and empty-state text.

## Source

- Registry detail: https://beui.dev/r/notification-stack
- Raw source: https://beui.dev/r/notification-stack/raw
- GitHub: https://github.com/starc007/ui-components
