# Notification Center

> Source: https://design.nanatec.co.ke/components/notification-center/
> A bell with an unread count that opens a panel of notifications, for the top bar of an app.

The notification center keeps what has happened since someone last looked: a bell in the
[top bar](/components/top-bar/) with the unread count, and a panel listing each
notification with how long ago it arrived. People can show only the unread, mark
everything read, or open one, which marks it read. For a message that needs no record, use
a [toast](/components/toaster/); for one that belongs on the page, an
[alert](/components/alert/).

## Preview

## Installation

```html
<nana-notification-center>
  <a slot="footer" href="/notifications">View all notifications</a>
</nana-notification-center>

<script type="module">
  const center = document.querySelector('nana-notification-center');
  center.items = [
    { id: 'clm-2041', title: 'Claim CLM-2041 approved', time: '2026-11-20T09:15:00Z' },
    { id: 'pay-118', title: 'Premium received', time: '2026-11-20T08:40:00Z', read: true },
  ];
  center.addEventListener('nana-select', (event) => console.log('open', event.detail.item.id));
  center.addEventListener('nana-change', (event) => console.log(event.detail.items));
</script>
```

The element replaces `items` when it marks notifications read, and fires `nana-change`
with the new list. Anything in the `footer` slot sits under the list.

## Times

Each time reads as how long ago it was, such as "5 min. ago" or "yesterday", in the page's
language, or in `locale` when set. The times are worked out each time the panel opens.

## Keyboard

| Key | Does |
| --- | --- |
| Enter or Space on the bell | Opens or closes the panel, moving focus into it |
| Tab | Moves through the panel's buttons and notifications |
| Up and Down arrows | Move between notifications |
| Home and End | Go to the first or last notification |
| Escape | Closes the panel and returns to the bell |

A press outside the panel also closes it.

## Accessibility

- The bell is named by `label`, "Notifications" by default, with the unread count added:
  "Notifications, 2 unread". The badge itself is hidden from screen readers.
- The panel is a dialog named by its heading. The All and Unread buttons say which is
  pressed.
- An unread notification starts with "Unread:" for screen readers; the dot and the bold
  title show it on screen.
- Each time is a `<time>` element carrying the exact date and time.
- The message shown when there is nothing to show is a status, so it is announced.

## API
