affectUI › Components › Feedback

Notification Stack

Notice cards stacked behind each other – dismiss the front one to reveal the next.

Free and open source (MIT). Install: npx shadcn@latest add https://www.affectui.com/r/notification-stack.json · Import from @/components/ui/notification-stack

When to use

  • A few announcements or notices in a corner of an app – releases, maintenance, invites
  • Toast-style messages that stay until someone dismisses them

When not to use

  • Messages that need an answer before people continue – use a dialog
  • Many notifications at once – past three or four, use an inbox or activity list

Usage

import { NotificationStack } from "@/components/ui/notification-stack";

const notices = [
  {
    id: "maintenance",
    badge: "Notice",
    title: "Scheduled maintenance",
    text: "We'll be offline on Sunday from 02:00 to 03:00 UTC.",
    action: { label: "View status", href: "/status", external: true },
    pattern: "grid",
  },
];

export function Notices() {
  return <NotificationStack notices={notices} onDismiss={(n) => markRead(n.id)} />;
}

Props

NameTypeDefaultDescription
noticesNotice[]id, badge, title, text, action ({ label, href, onClick, external }) and pattern
onDismiss(notice: Notice) => voidCalled when a notice is dismissed with its close button
classNamestringExtra class on the stack

Keyboard

  • Tab: Move through the front card's buttons
  • Enter / Space: Run the action or dismiss the notice

Accessibility

  • The stack is a labelled region; each card is an article named by its title
  • Only the front card is read out and focusable; the next one takes its place after a dismiss

Responsive

  • Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"

Requirements

  • React 19

Related

  • Decision Inbox – Open decisions with two quick answers each – answered ones confirm and fold away
  • Tips Panel – Grid of short tips with one action each – taken tips turn into a done state