Navigation

v2.1.0
Application blocks

Notification inbox

Notifications in a page: all or unread, read one by one or all at once.

A notification inbox is the page of what happened while the reader was away: who did it or what it was, when, and whether it has been read. It filters to what is unread and marks one or all as read. The notifications are a list on a sheet, under a segmented control.

Notification inbox

<section class="sheet container-inline flex flex-col overflow-hidden max-w(640) mx-auto" data-example="notification-inbox" aria-labelledby="inbox-title">  <header class="flex flex-wrap items-center justify-between gap-sm p-md">    <div class="flex flex-col gap-3xs">      <h2 class="heading heading-sm" id="inbox-title">Notifications</h2>      <p class="m(0) fg-text-muted" data-inbox-count>4 unread</p>    </div>    <div class="flex flex-wrap items-center gap-xs">      <div class="segmented segmented-sm" role="radiogroup" aria-label="Show">        <label class="segmented-item">          <input type="radio" class="segmented-input" name="inbox-filter" value="all" checked disabled>All</label>        <label class="segmented-item">          <input type="radio" class="segmented-input" name="inbox-filter" value="unread" disabled>Unread</label>      </div>      <button type="button" class="btn btn-sm" data-inbox-read-all disabled>Mark all as read</button>    </div>  </header>  <div class="px-md bt(1) bt-solid b-line-hair">    <ul class="list" aria-label="Notifications" data-inbox-list>      <li class="list-row" data-unread>        <span class="avatar list-media">          <img class="avatar-image" src="/demo/people/kenta-nakamura.webp" alt width="256" height="256">        </span>        <div class="list-body">          <p class="list-title">            <a class="link link-quiet" href="#inbox-title">Kenta Nakamura mentioned you</a>          </p>          <p class="list-description">“Can you check the edge logs?”</p>        </div>        <p class="list-meta">          <time datetime="2026-11-13T09:31">Today, 09:31</time>          <span class="badge badge-sm badge-dot" data-inbox-unread>Unread</span>        </p>        <span class="list-end">          <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Mark “Kenta Nakamura mentioned you” as read" data-inbox-read disabled>            <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">              <path d="M3 8L6.3532 11.3532A0.2 0.2 0 0 0 6.6412 11.3479L13 4.5" />            </svg>          </button>        </span>      </li>      <li class="list-row" data-unread>        <span class="icon-frame icon-frame-xs list-media" aria-hidden="true">          <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">            <path d="M8.8742 3.8235L13.4246 12.0144A1 1 0 0 1 12.5505 13.5L3.4495 13.5A1 1 0 0 1 2.5754 12.0144L7.1258 3.8235A1 1 0 0 1 8.8742 3.8235Z" />            <path d="M8 6.5L8 9" />            <circle cx="8" cy="11.5" r="0.5" fill="currentColor" stroke="none" />          </svg>        </span>        <div class="list-body">          <p class="list-title">            <a class="link link-quiet" href="#inbox-title">Deployment failed on atlas.dev</a>          </p>          <p class="list-description">The install step failed.</p>        </div>        <p class="list-meta">          <time datetime="2026-11-13T09:12">Today, 09:12</time>          <span class="badge badge-sm badge-dot" data-inbox-unread>Unread</span>        </p>        <span class="list-end">          <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Mark “Deployment failed on atlas.dev” as read" data-inbox-read disabled>            <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">              <path d="M3 8L6.3532 11.3532A0.2 0.2 0 0 0 6.6412 11.3479L13 4.5" />            </svg>          </button>        </span>      </li>      <li class="list-row" data-unread>        <span class="avatar list-media">          <img class="avatar-image" src="/demo/people/misaki-sato.webp" alt width="256" height="256">        </span>        <div class="list-body">          <p class="list-title">            <a class="link link-quiet" href="#inbox-title">Misaki Sato left a comment</a>          </p>          <p class="list-description">“The hero reads much better.”</p>        </div>        <p class="list-meta">          <time datetime="2026-11-12T17:40">Yesterday, 17:40</time>          <span class="badge badge-sm badge-dot" data-inbox-unread>Unread</span>        </p>        <span class="list-end">          <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Mark “Misaki Sato left a comment” as read" data-inbox-read disabled>            <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">              <path d="M3 8L6.3532 11.3532A0.2 0.2 0 0 0 6.6412 11.3479L13 4.5" />            </svg>          </button>        </span>      </li>      <li class="list-row" data-unread>        <span class="icon-frame icon-frame-xs list-media" aria-hidden="true">          <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">            <circle cx="8" cy="8" r="6" />            <path d="M8 4.3333L8 7.8892A0.2 0.2 0 0 0 8.094 8.0588L10.6667 9.6667" />          </svg>        </span>        <div class="list-body">          <p class="list-title">            <a class="link link-quiet" href="#inbox-title">Build minutes are at 62%</a>          </p>          <p class="list-description">760 minutes are left.</p>        </div>        <p class="list-meta">          <time datetime="2026-11-12T08:00">Yesterday, 08:00</time>          <span class="badge badge-sm badge-dot" data-inbox-unread>Unread</span>        </p>        <span class="list-end">          <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Mark “Build minutes are at 62%” as read" data-inbox-read disabled>            <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">              <path d="M3 8L6.3532 11.3532A0.2 0.2 0 0 0 6.6412 11.3479L13 4.5" />            </svg>          </button>        </span>      </li>      <li class="list-row">        <span class="avatar list-media">          <img class="avatar-image" src="/demo/people/pohan-chen.webp" alt width="256" height="256">        </span>        <div class="list-body">          <p class="list-title">            <a class="link link-quiet" href="#inbox-title">Po-han Chen invited you to Borealis</a>          </p>          <p class="list-description">You joined as a member.</p>        </div>        <p class="list-meta">          <time datetime="2026-11-11T14:05">11 November</time>        </p>      </li>      <li class="list-row">        <span class="icon-frame icon-frame-xs list-media" aria-hidden="true">          <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">            <path d="M4.4667 2L11.5333 2A0.8 0.8 0 0 1 12.3333 2.8L12.3333 12.7907A0.7018 0.7018 0 0 1 11.2833 13.4L10.4293 12.912A0.8 0.8 0 0 0 9.5886 12.9409L8.4438 13.7042A0.8 0.8 0 0 1 7.5562 13.7042L6.4114 12.9409A0.8 0.8 0 0 0 5.5707 12.912L4.7167 13.4A0.7018 0.7018 0 0 1 3.6667 12.7907L3.6667 2.8A0.8 0.8 0 0 1 4.4667 2Z" />            <path d="M6 5.3333L10 5.3333" />            <path d="M6 8.3333L10 8.3333" />          </svg>        </span>        <div class="list-body">          <p class="list-title">            <a class="link link-quiet" href="#inbox-title">Invoice INV-2026-011 was paid</a>          </p>          <p class="list-description">$100.00 for November.</p>        </div>        <p class="list-meta">          <time datetime="2026-11-01T00:00">1 November</time>        </p>      </li>    </ul>    <div data-inbox-empty hidden>      <div class="empty">        <span class="icon-frame empty-media" aria-hidden="true">          <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">            <path d="M3.5 10L7.8545 14.3545A0.2 0.2 0 0 0 8.1413 14.3504L16.5 5.5" />          </svg>        </span>        <h3 class="empty-title">You have read everything</h3>        <p class="empty-description">Nothing is unread. What arrives next is listed here first.</p>        <div class="empty-actions">          <button type="button" class="btn btn-sm" data-inbox-show-all>Show all notifications</button>        </div>      </div>    </div>  </div>  <p class="sr-only" role="status" data-inbox-status></p></section>
Switch to Unread, mark one notification as read with its check, then mark the rest. What is read is kept for this preview only.

Blocks are markup to copy. They take the page's own text color and size; the previews set fg-text-body text-sm on the body. Each block is a size container, so it reflows by its own width: in a wide page, a sidebar's worth of room or a dialog.

#What is in it

  • One sheet at a reading width, max-w(640): a header with the title, the count and the controls, then the list. In a narrow block the controls wrap under the title.
  • The count is words under the title: "4 unread". It is the same number the rows show, since both are drawn from one state.
  • All or Unread is a segmented of two native radios. A filter is one choice among a few, which is what a radio group is; the browser keeps its arrow keys and its checked state, and nothing is announced as "selected" that is not.
  • Each notification is a list-row: who or what as list-media, a title that is a link to the thing itself, one line of detail, and under them when it arrived. A person is an avatar; the system is an icon frame, so a deployment that failed does not borrow a face.
  • Unread is a word. A neutral badge with a dot reads "Unread" beside the time. It is not aria-current and not aria-selected: neither means "not yet read", and a row is not chosen by being new.
  • One quiet button at the end of an unread row marks it read. Its name carries the row's title: "Mark “Deployment failed on atlas.dev” as read". A row that has been read has no button and no badge.
  • "Mark all as read" stands with the filter, not with the rows, and is disabled while nothing is unread.
  • Nothing unread is not nothing at all. When the Unread filter is left with no rows, an empty says "You have read everything" and offers the way back to all of them. An inbox that has never had a notification is a different state with different words.

The title and the detail each keep one line and end in an ellipsis: a notification is a pointer to the thing, and the thing holds the rest.

#What needs a script

The rows are in the markup, so the inbox reads in full without the script; its controls are disabled there and the script turns them on. main.js then keeps one list: every notification and whether it is unread, read once from the rows. Everything is drawn from it.

  • The filter shows every row or the unread ones. The count, the rows and the empty result cannot disagree, because none of them is kept separately.
  • Marking one read takes the badge and the button out of its row. Under Unread the row leaves the list as well.
  • Focus follows. After a row is marked read, focus goes to the next unread row's button, then to the one before, and when none is left, to the filter. "Mark all as read" hands focus to the filter before it is disabled.
  • One polite status line, not drawn, says the result and what is left: "“Kenta Nakamura mentioned you” marked as read. 3 unread."

What is read is kept for the visit only. In an application the same function sends the change to the server, and puts the row back as unread if that fails; new notifications are added to the list and counted the same way. The block stays in the page: it is not the popover under a bell, and it sends no push notification.

#Accessibility

  • The block is a <section> named by its <h2>, and the list is a <ul> named "Notifications".
  • The filter is a radiogroup named "Show". Tab reaches the checked option and the arrow keys move the choice.
  • Each row has two targets, and each says what it does: the title goes to the thing, the button marks the row read. The check in the button is decoration; the name is in aria-label.
  • A portrait beside a name has an empty alt, and an icon frame is aria-hidden: the title already says who or what.
  • The time is a <time> with a datetime. "Today, 09:31" is for the reader; the attribute is for everything else.
  • The status line is role="status", so a result is announced without moving focus, and focus never falls back to the top of the page when a row leaves.
  • On a touch screen the 32px buttons keep their size and their target grows to 44px.