Notification Inbox

Pro

Notifications as a split layout. The list fills the space until you click one, then the notification opens beside it with who sent it, where it came from and what to do next. On a narrow screen it slides over the list.

Installation#

# One-time setup (tokens + lib helpers)npx koalaui-cli@latest init# Activate your Pro license (once per machine)npx koalaui-cli@latest login <key># Add this component (its dependencies come along)npx koalaui-cli@latest add notification-inbox

Usage#

The inbox owns the layout and which notification is open. The data stays yours: filter the rows you render for a search or a tab, mark a notification read in onValueChange, and the pager follows whatever rows are on screen.

This example is part of Koala UI Pro

The preview is yours to explore. Its code comes with a Pro license, paid once and used in every project.

Have a license? Unlock it here

Anatomy#

import {  NotificationInbox,  NotificationInboxList,  NotificationInboxBar,  NotificationInboxScroll,  NotificationInboxGroup,  NotificationInboxItem,  NotificationInboxItemMedia,  NotificationInboxItemContent,  NotificationInboxItemTitle,  NotificationInboxItemDescription,  NotificationInboxItemMeta,  NotificationInboxDetail,  NotificationInboxClose,  NotificationInboxPager,  NotificationInboxContent,  NotificationInboxFields,  NotificationInboxTitle,  NotificationInboxBody,  NotificationInboxActions,} from "@/components/ui/notification-inbox"<NotificationInbox>  <NotificationInboxList>    <NotificationInboxBar />    <NotificationInboxScroll>      <NotificationInboxGroup>        <NotificationInboxItem>          <NotificationInboxItemMedia />          <NotificationInboxItemContent>            <NotificationInboxItemTitle />            <NotificationInboxItemDescription />          </NotificationInboxItemContent>          <NotificationInboxItemMeta />        </NotificationInboxItem>      </NotificationInboxGroup>    </NotificationInboxScroll>  </NotificationInboxList>  <NotificationInboxDetail>    <NotificationInboxBar>      <NotificationInboxClose />      <NotificationInboxPager />    </NotificationInboxBar>    <NotificationInboxContent>      <NotificationInboxFields />      <NotificationInboxTitle />      <NotificationInboxBody />      <NotificationInboxActions />    </NotificationInboxContent>  </NotificationInboxDetail></NotificationInbox>

In a dialog#

Open it from the bell in the top bar. Strip the dialog’s padding so the inbox runs edge to edge, keep the title above it, and give the dialog a height. On a phone the dialog becomes a sheet and the inbox switches to one side at a time.

API reference#

NotificationInbox

The split and the state its two sides share: which notification is open. Nothing is open until a row is clicked, and the list takes the full width. It is its own container: from 40rem wide the detail opens as a pane beside the list and the list narrows to listWidth, below that the detail slides over the list. Give it a height. Forwards native <div> props.

PropTypeDefaultDescription
valuestring | null-Controlled. The open notification's value.
defaultValuestring | nullnullInitial open notification when uncontrolled.
onValueChange(value: string | null) => void-Called when a row, the pager or the back button changes the open notification. Mark it read here.
listWidthstring"22rem"Width the list narrows to while a notification is open beside it.
Data attributeDescription
data-openPresent while a notification is open.

NotificationInboxList

The list column, a labelled region. Hidden below 40rem while the detail covers it. Forwards native <div> props.

PropTypeDefaultDescription
aria-labelstring"Notifications"Names the region.

NotificationInboxBar

A 48px bar with a hairline under it, for the search and filter row on the list side and the actions on the detail side. Both sides use the same bar, so their hairlines meet. Forwards native <div> props.

NotificationInboxScroll

The scrolling area under the bars. Forwards native <div> props.

NotificationInboxGroup

A run of rows under a day or a section label. It is a single-select listbox: arrow keys move between rows, the open one is selected. Forwards native <div> props.

PropTypeDefaultDescription
labelReactNode-The heading above the rows, and the listbox's name.

NotificationInboxItem

One row. Opens its notification on click and moves focus to the detail when the detail covers the list. Forwards native <button> props.

PropTypeDefaultDescription
valuestring-Required. Identifies the notification.
unreadbooleanfalseMedium-weight title, a dot under the time and an "Unread" prefix for screen readers.

NotificationInboxItemMedia

The leading avatar or icon. Put the type glyph in an AvatarBadge.

NotificationInboxItemContent

The column for the title and the description.

NotificationInboxItemTitle

One line, truncated.

NotificationInboxItemDescription

One line by default; lines takes 1, 2, 3 or "none".

NotificationInboxItemMeta

The time, with the unread dot under it when the row is unread.

NotificationInboxDetail

The detail side, a labelled section, hidden until a notification is open. From 40rem it grows in from the right as the list narrows, below that it slides in over the list. Keep the last notification's content in it while it closes. Forwards native <section> props.

PropTypeDefaultDescription
aria-labelstring"Notification"Names the section.
Data attributeDescription
data-stateopen or closed.

NotificationInboxClose

Closes the detail and returns focus to its row. A cross at the end of the bar when the detail sits beside the list, a back arrow at the start when it covers the list.

NotificationInboxPager

"2 of 6" and previous and next buttons, in the order the rows are on screen right now, so a search or a tab narrows it too. Renders nothing when the open notification is not in the list.

NotificationInboxContent

The scrolling body of the detail.

NotificationInboxFields

A DescriptionList laid out as wrapping columns, term over value: From, Folder, Received, Type. Fill it with DescriptionListItem, DescriptionTerm and DescriptionDetails.

NotificationInboxTitle

The notification's heading, an <h2>.

NotificationInboxBody

The message, at reading measure.

NotificationInboxActions

A row for what to do next, usually one primary button.

FAQ#

The list is what you came to scan. A notification opens only when you click it, and the list narrows to make room, so the pane always answers something you did. Pass defaultValue to open one on mount.