# React Native Notification Center (Pro)

> A React Native notification inbox for iOS, Android and the web: a bell with a live unread count, tabs for All, Unread, Mentions and Archived, a filter by kind, notifications grouped by day, swipe or hover to mark read, snooze or archive, inline Accept and Decline buttons, a New pill for arrivals, settings, and loading and empty states. A popover on wide screens, a sheet on phones. Part of Patine Pro.

# Notification center Pro

`NotificationCenter` is the bell in an app's top bar and the inbox it opens, as Linear, GitHub and Slack have it. Tabs for **All**, **Unread**, **Mentions** and **Archived**, a filter by kind, notifications grouped by day (Today, Yesterday, the weekday, then the date), each with who or what it's from, where it happened, a short time and its own buttons. Swipe one right to mark it read, left to snooze or archive (a long swipe archives); with a pointer the same actions show on hover. Notifications that arrive while you're reading wait behind a **New** pill instead of pushing the list, and the bell's count pops when it goes up. It opens by the bell on wide screens and as a sheet on phones. `NotificationInbox` is the inbox without the bell, for a full-page Inbox screen.

For a message that comes and goes, use the free [Toast](../components/toast).

```tsx
import { NotificationCenter, NotificationInbox } from '@patine-ui/pro';
```

```tsx live
import { useState } from 'react';
import { NotificationCenter } from '@patine-ui/pro';

const NOW = Date.now();
const INITIAL = [
  { id: '1', title: 'Maya mentioned you in Q4 funnel', body: '“Can you check the drop at verify email?”', context: 'Funnels · Q4 activation', createdAt: NOW - 4 * 60000, kind: 'mention', actor: { name: 'Maya Lindqvist' } },
  { id: '2', title: 'Leo invited you to Growth', body: '6 members · 14 shared reports', createdAt: NOW - 3 * 3600000, actor: { name: 'Leo Brandt' }, actions: [{ label: 'Accept', primary: true, onPress: () => {} }, { label: 'Decline', onPress: () => {} }] },
  { id: '3', title: 'Event volume at 84% of your plan', body: 'Upgrade before Nov 28 to keep ingesting.', createdAt: NOW - 20 * 3600000, kind: 'system', icon: 'gauge', tone: 'warning' },
  { id: '4', title: 'Payment failed', body: 'Card ending 4242 was declined. We’ll retry tomorrow.', createdAt: NOW - 2 * 86400000, kind: 'system', icon: 'card', tone: 'danger', read: true },
  { id: '5', title: 'Weekly report is ready', createdAt: NOW - 6 * 86400000, icon: 'lineChart', read: true, archived: true },
];

export default function Example() {
  const [list, setList] = useState(INITIAL);
  const update = (id, patch) => setList((l) => l.map((n) => (n.id === id ? { ...n, ...patch } : n)));
  return (
    <NotificationCenter
      notifications={list}
      onMarkRead={(id) => update(id, { read: true })}
      onMarkUnread={(id) => update(id, { read: false })}
      onArchive={(id) => update(id, { archived: true, read: true })}
      onSnooze={(id, until) => update(id, { snoozedUntil: until })}
      onMarkAllRead={() => setList((l) => l.map((n) => ({ ...n, read: true })))}
      onOpenSettings={() => {}}
    />
  );
}
```

## A full-page inbox

`NotificationInbox` takes the same props and draws the inbox in place, for an Inbox screen or a side panel. Hover a notification for its actions; on a phone, swipe it.

```tsx live
import { useState } from 'react';
import { NotificationInbox } from '@patine-ui/pro';

const NOW = Date.now();
const INITIAL = [
  { id: '1', title: 'Ana replied to your comment', body: '“Let’s ship the warehouse sync behind a flag first.”', context: 'Roadmap · Warehouse sync', createdAt: NOW - 12 * 60000, kind: 'mention', actor: { name: 'Ana Ferreira' } },
  { id: '2', title: 'Copilot flagged a 25% jump in signups', body: 'Most of it came from the Product Hunt launch.', createdAt: NOW - 52 * 60000, icon: 'sparkles' },
  { id: '3', title: 'Incident resolved: delayed ingestion', body: 'EU-West events were up to 9 minutes late.', createdAt: NOW - 26 * 3600000, kind: 'system', icon: 'activity', tone: 'success', read: true },
  { id: '4', title: 'Jonas moved “Retention cohorts v2” to Review', context: 'Board · Sprint 46', createdAt: NOW - 3 * 86400000, actor: { name: 'Jonas Weber' }, read: true },
];

export default function Example() {
  const [list, setList] = useState(INITIAL);
  const update = (id, patch) => setList((l) => l.map((n) => (n.id === id ? { ...n, ...patch } : n)));
  return (
    <NotificationInbox
      style={{ width: '100%', maxWidth: 420, borderRadius: 12, borderWidth: 1, borderColor: 'rgba(127,127,127,0.25)', overflow: 'hidden' }}
      notifications={list}
      onMarkRead={(id) => update(id, { read: true })}
      onMarkUnread={(id) => update(id, { read: false })}
      onArchive={(id) => update(id, { archived: true, read: true })}
      onSnooze={(id, until) => update(id, { snoozedUntil: until })}
      onMarkAllRead={() => setList((l) => l.map((n) => ({ ...n, read: true })))}
    />
  );
}
```

## Snooze and archive

`onArchive` adds Archive (a long swipe left, or the button on hover) and the **Archived** tab. `onSnooze(id, until)` adds Snooze, with a choice of when it comes back: in an hour, this evening (before 5 PM), tomorrow morning, or next Monday morning. A snoozed notification leaves the inbox and comes back by itself once `snoozedUntil` has passed; the header counts how many are snoozed. `onMarkUnread` adds Mark as unread.

## Live arrivals

Add notifications to the list as they arrive, from a socket or a poll. At the top of the list they simply show; scrolled down, they wait behind a **↑ 2 new** pill that scrolls up to them, so what you're reading doesn't move. The bell's count pops each time it goes up.

## Filters, settings and states

The filter button narrows to one kind (`mention`, `activity` or `system`); a note under the tabs says so with **Clear**. `onOpenSettings` adds a settings button to the header. `loading` shows skeleton rows, and each tab has its own empty state: "You’re all caught up" for Unread, "No mentions", "Nothing archived".

## In the app's top bar

Put it in [AppShell](../pro/layout)'s `actions`, which draw a top bar on tablets and desktops.

```tsx
<AppShell {...shell} actions={<NotificationCenter notifications={notifications} onMarkAllRead={markAllRead} onArchive={archive} />}>
```

## Accessibility

- The bell says the count: "Notifications, 3 unread". The panel is a dialog named Notifications that closes with Escape and Back.
- Each notification reads as one line, starting with "Unread" when it is, with where it happened and when; it opens with `onPress`, which also marks it read. Its buttons sit beside it, not inside it.
- Days are headings; tabs are a segmented control. Swipe actions are also buttons on hover, and Snooze opens a menu or a sheet of choices with their times. The New pill says how many and what it does.

## Props

| Prop | Type | Default |
| --- | --- | --- |
| `notifications` | `{ id, title, body?, createdAt, read?, kind?, actor?, icon?, tone?, context?, actions?, archived?, snoozedUntil? }[]` | |
| `onPress` | `(notification) => void` | |
| `onMarkRead`, `onMarkUnread` | `(id) => void` | |
| `onMarkAllRead` | `() => void`: shows Mark all read | |
| `onArchive` | `(id) => void`: adds Archive and the Archived tab | |
| `onSnooze` | `(id, until) => void`: adds Snooze | |
| `onOpenSettings` | `() => void`: a settings button in the header | |
| `loading` | `boolean`: skeleton rows | `false` |
| `open`, `onOpenChange` | the panel, controlled (NotificationCenter) | |
| `width` | `number`, the panel on wide screens (NotificationCenter) | `400` |
| `now` | `number`, pins the times in tests | |

`notificationsFor(list, tab, now?, filter?)`, `unreadCount(list, now?)` and `snoozeOptions(now)` are exported for your own badges and menus.

## Related

- [Toast](../components/toast): a passing message, free.
- [Swipeable row](../components/swipeable-row): the swipe behind it, free.
- [App layout](../pro/layout): the top bar it sits in.
