# Notification Inbox

> A bell with an unread count that opens a notification popover: All and Mentions tabs, unread dots, mark all read, type icons and an empty state. Built in React.

- Kind: Component (Overlays)
- Docs: https://ui.minidev.pro/docs/notification-inbox
- Source (registry JSON with the full file): https://ui.minidev.pro/r/notification-inbox.json
- License: MIT. One file, yours to edit after install.

## When to use

Built on Base UI Popover: focus moves in on open, Escape closes and returns focus to the bell, whose accessible name includes the unread count. Opening a row marks it read. Use it in app headers; for a single row use NotificationItem, for settings use NotificationPreferences.

## Installation

### shadcn CLI (copies the source into your project)

```bash
npx shadcn@latest add @minidev/notification-inbox
```

Writes `components/ui/notification-inbox.tsx` and installs its npm dependencies. Older CLI versions: `npx shadcn@latest add https://ui.minidev.pro/r/notification-inbox.json`.

### npm package

```bash
npm i minidev-ui-kit @base-ui/react lucide-react
```

Add the tokens to your global stylesheet once:

```css
@import "tailwindcss";
@import "minidev-ui-kit/styles.css";
@source "../node_modules/minidev-ui-kit";
```

Next.js also needs `transpilePackages: ["minidev-ui-kit"]` in next.config.

## Import

After the shadcn install:

```tsx
import { NotificationInbox } from "@/components/ui/notification-inbox"
```

From the npm package:

```tsx
import { NotificationInbox } from "minidev-ui-kit/ui/notification-inbox"
```

## Usage

```tsx
import { NotificationInbox } from "@/components/ui/notification-inbox"

export function Example() {
  return (
    <NotificationInbox />
  )
}
```

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `notes` | `Note[]` | `SAMPLE` | no | Initial notifications, newest first. The inbox then tracks read state itself. |
| `onOpenNote` | `(note: Note) => void` | - | no | Called when a notification is opened (it is also marked read). |
| `onMarkAllRead` | `() => void` | - | no | Called after "Mark all read". |
| `viewAllHref` | `string` | `"#"` | no | Footer link to the full activity page. Omit to hide the footer. |
| `className` | `string` | - | no | Classes for the bell trigger. |

## Examples

### Your notifications

notes seeds the list once; onOpenNote fires when a row is opened, which also marks it read.

```tsx
function OpenDemo() {
  const [opened, setOpened] = React.useState<string | null>(null)
  return (
    <div className="flex items-center gap-3">
      <NotificationInbox
        viewAllHref="/activity"
        notes={[
          { id: "a1", kind: "review", who: "Priya Raman", text: "asked you to review the October close", time: "4m", unread: true },
          { id: "a2", kind: "mention", who: "Sam Lowe", text: "mentioned you on INV-2041: \"can you resend this?\"", time: "1h", unread: true },
          { id: "a3", kind: "invite", who: "Halcyon Studio", text: "invited you to the Payroll workspace", time: "Tue" },
        ]}
        onOpenNote={(n) => setOpened(n.who + " " + n.text)}
      />
      <p className="max-w-56 text-xs text-fg-muted" aria-live="polite">{opened ? "Opened: " + opened : "Open the bell and pick a notification."}</p>
    </div>
  )
}
```

### Empty inbox, no footer

With no notes the bell has no count and the list shows its caught-up message; viewAllHref="" removes the footer link.

```tsx
<NotificationInbox notes={[]} viewAllHref="" />
```

## Keyboard interactions

| Key | Action |
| --- | --- |
| `Enter` or `Space` | On the bell, opens the inbox and moves focus inside. |
| `Tab` or `Shift+Tab` | Moves through All, Mentions, Mark all read, each notification and the footer link. |
| `Enter` or `Space` | On a notification, opens it and marks it read. |
| `Escape` | Closes the inbox and returns focus to the bell. |

## Accessibility

- The bell's accessible name includes the count, such as "Notifications, 3 unread". The visual count badge is `aria-hidden` and caps at "99+".
- All and Mentions are buttons with `aria-pressed`, not a tablist, so the arrow keys do not move between them.
- Each unread row ends with screen-reader text "Unread"; avatars and kind icons are `aria-hidden`.
- The popup is labelled "Notifications". Its fade and scale are CSS transitions, cut to 0.01ms under `prefers-reduced-motion: reduce`.

## FAQ

### Why don't new notifications appear when I update `notes`?

`notes` is only the starting list: it seeds internal state on mount, and the inbox tracks read state itself from then on. To show new items, remount it with a changing `key`, such as `key={latestId}`, or copy the file and make `notes` controlled.

### How do I sync read state with my server?

Use `onOpenNote(note)`, called when a row is opened and marked read, and `onMarkAllRead()`. Send the change to your API from there. Opening a row does not close the popover, so navigate or show the item from `onOpenNote`.

### How do I hide the View all activity link?

Pass `viewAllHref=""`. The default is `"#"`, which shows the footer.

## Rules for generating code

- Use semantic tokens only (bg, surface, sunken, border, fg, fg-muted, fg-subtle, ink, accent, success, warning, danger). Never raw hex or palette steps like blue-500.
- Shadows only from the set: shadow-xs, shadow-sm, shadow-raised, shadow-md, shadow-lg, shadow-overlay.
- Numbers use tabular-nums. Dark mode is the `dark` class on <html>; components never branch on theme.

## Dependencies

- npm: `@base-ui/react`, `lucide-react`

## Related

- [Popover](https://ui.minidev.pro/docs/popover/md): A floating React panel anchored to a trigger, built on Base UI with side and align options, collision aware positioning, title and description parts.
- [Notification Item](https://ui.minidev.pro/docs/notification-item/md): A single notification row with an unread dot and tint, a truncated title, relative time and a short body line. Stack it in React inboxes and activity feeds.
- [Notification Preferences](https://ui.minidev.pro/docs/notification-preferences/md): A notification settings list of labeled switches for email digests, product updates and security alerts. A simple React start for preference pages.
- [Notification Center](https://ui.minidev.pro/docs/notification-center/md): A React notification center card with a settings action and a stack of notification items showing title, body, relative time and an unread marker.
- [Alert Dialog](https://ui.minidev.pro/docs/alert-dialog/md): Shadcn style alert dialog on Base UI for confirmations that need an explicit answer. Modal backdrop, focus trap, title, description and an actions row.
- [Command Dialog](https://ui.minidev.pro/docs/command-dialog/md): Command dialog that opens the command palette in a modal from a list of commands with labels and handlers. Wire it to a Cmd K shortcut in your React app.

---

All 557 components: https://ui.minidev.pro/llms.txt (full text: https://ui.minidev.pro/llms-full.txt).
