# Notification stack

New updates slide into a layered stack with individual dismiss controls.

## Usage

Use as a starting point for a bounded list of updates. The demo caps the list at three and does not auto-dismiss messages. Connect it to actual events; do not use confirmations for operations that have not succeeded.

Save the JSX and CSS Module in the same folder in a React project with CSS Modules support. Controlled components need parent state and change handlers.

## JSX

```jsx
"use client";
import styles from "./NotificationStack.module.css";
import { useState, useRef } from "react";
export default function NotificationStack({
  title = "Your workspace is up to date.",
}) {
  const next = useRef(2);
  const [items, setItems] = useState([{ id: 1, title }]);
  return (
    <div className={styles.root}>
      <div className={styles.stack} aria-label="Recent notifications">
        {items.map((item, index) => (
          <div
            className={styles.note}
            key={item.id}
            style={{ "--index": index }}
          >
            <span className={styles.dot} aria-hidden="true">
              ✓
            </span>
            <div>
              <strong>All set</strong>
              <p>{item.title}</p>
            </div>
            <button
              type="button"
              aria-label={`Dismiss notification ${item.id}`}
              onClick={() =>
                setItems((previous) =>
                  previous.filter((entry) => entry.id !== item.id),
                )
              }
            >
              ×
            </button>
          </div>
        ))}
      </div>
      <div className={styles.controls}>
        <button
          type="button"
          onClick={() => {
            const notification = { id: next.current++, title };
            setItems((previous) => [notification, ...previous].slice(0, 3));
          }}
        >
          Add notification <span aria-hidden="true">+</span>
        </button>
        <span role="status">{items.length} of 3</span>
      </div>
    </div>
  );
}

```

## CSS

```css
.root {
  width: 320px;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100px;
  perspective: 600px;
}
.note {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 12px;
  background: var(--tdp-surface, #fffdfa);
  border: 1px solid var(--tdp-border, #d9d1c9);
  border-radius: var(--tdp-radius, 8px);
  box-shadow: 0 5px 15px #35291a08;
  animation: arrive 0.35s ease-out both;
  transition: transform 0.25s;
}
.note:hover {
  transform: translateX(4px);
}
.note strong {
  font-size: 12px;
  font-weight: 600;
}
.note p {
  font-size: 10px;
  color: var(--tdp-muted, #6b625b);
  margin: 4px 0 0;
  line-height: 1.5;
}
.dot {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  background: #e1edd9;
  color: #446234;
  font-size: 11px;
}
.note > button {
  margin-left: auto;
  min-width: 32px;
  min-height: 44px;
  background: transparent;
  border: 0;
  font-size: 20px;
  color: #7f7368;
}
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  gap: 10px;
}
.controls > button {
  min-height: 44px;
  background: transparent;
  border: 0;
  padding: 8px 0;
  color: var(--tdp-text, #302e2b);
  font-size: 12px;
}
.controls > span {
  font: 10px monospace;
  color: var(--tdp-muted, #6b625b);
}
@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.root {
  font-family: var(--tdp-font, "DM Sans", system-ui, sans-serif);
  color: var(--tdp-text, #302e2b);
  max-width: 100%;
  box-sizing: border-box;
}
.root * {
  box-sizing: border-box;
}
.root :is(button, input, a):focus-visible,
.root:focus-visible {
  outline: 3px solid var(--tdp-focus, #7851a9);
  outline-offset: 4px;
}
.root button {
  font: inherit;
  cursor: pointer;
}
.root button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.root button,
.root a {
  touch-action: manipulation;
}
@media (prefers-reduced-motion: reduce) {
  .root,
  .root *,
  .root::before,
  .root::after {
    animation: none !important;
    transition: none !important;
    transform: none !important;
    translate: none !important;
    rotate: none !important;
    scale: none !important;
    scroll-behavior: auto !important;
  }
}

```

## Props

- title (string): Message used by the demonstration trigger.

## Accessibility

Every notification has a named dismiss button. Count changes are announced without making the entire stack repeatedly speak. Essential messages stay until dismissed or replaced by the bounded list.

Check accessibility again after customizing the component.

[Browse all components](/resources/components/)

Canonical: https://designproject.io/resources/components/notification-stack/

## Keep learning

- [How to create a UI color palette, step by step](https://designproject.io/resources/guides/create-ui-color-palette/)
- [Product design glossary: 44 terms explained](https://designproject.io/resources/glossary/)
- [How to choose font pairings for a product interface](https://designproject.io/resources/guides/choose-font-pairings/)
