Notification Center
An inbox panel of notifications grouped by day, with read and unread states and mark all as read.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
notifications | NotificationItem[] | [] | The notifications. As an attribute, a JSON array of { id, title, body, time, read, href, avatar, group }. |
filter | 'all' | 'unread' | all | Which notifications are listed. The All / Unread buttons set it. |
group-by | 'day' | 'field' | 'none' | day | How the list is grouped: by day (Today, Yesterday, then the date), by each item's group, or not at all. |
has-more | boolean | false | Adds a Load more button at the end of the list, which fires load-more. |
loading | boolean | false | Marks the Load more button busy while the next page arrives. |
label | string | — | The title. Defaults to "Notifications" in the page's language. |
Slots
| Name | Description |
|---|---|
empty | Replaces the message shown when there is nothing to list. |
header-actions | More controls at the end of the header, such as a settings button. |
Events
| Name | Type | Description |
|---|---|---|
read-change | CustomEvent<{ ids: (string | number)[]; read: boolean }> | The user marked items read or unread. Cancelable: cancel it to leave notifications unchanged. |
notification-click | CustomEvent<{ notification: NotificationItem }> | An item was activated. Cancelable: cancelling it keeps the item unread and stops a link from being followed. |
filter-change | CustomEvent<{ filter: 'all' | 'unread' }> | The user switched between All and Unread; filter is already updated. |
load-more | Event | The Load more button was pressed. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
header | The row with the title, the unread count and the actions. |
title | The title. |
filters | The All / Unread buttons. |
mark-all | The Mark all as read button. |
group-title | A day's (or group's) title. |
item | One notification. |
dot | The unread dot. |
item-title | An item's title. |
body | An item's second line. |
time | An item's time. |
toggle | An item's read / unread toggle. |
empty | The message shown when there is nothing to list. |
load-more | The Load more button. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-notification-center--width | pixel | 380px | |
--c2-notification-center--max-height | pixel | 520px | The list scrolls past it. |
--c2-notification-center--background-color | color | #ffffff | |
--c2-notification-center--border | border | 1px solid #e4e4e7 | |
--c2-notification-center--border-radius | border-radius | 8px | |
--c2-notification-center--box-shadow | shadow | none | |
--c2-notification-center--color | color | #18181b | |
--c2-notification-center--font-size | font-size | 14px | |
--c2-notification-center__header--padding | padding | 12px 16px 8px | |
--c2-notification-center__title--font-weight | font-weight | 600 | |
--c2-notification-center__group-title--color | color | #71717a | |
--c2-notification-center__group-title--font-size | font-size | 12px | |
--c2-notification-center__item--padding | padding | 10px 16px | |
--c2-notification-center__item--gap | pixel | 12px | |
--c2-notification-center__item__hover--background-color | color | #fafafa | |
--c2-notification-center__item__unread--background-color | color | #edf1fe | An unread item's background. |
--c2-notification-center__dot--color | color | rgb(2, 101, 220) | |
--c2-notification-center__dot--size | pixel | 8px | |
--c2-notification-center__item-title__unread--font-weight | font-weight | 600 | |
--c2-notification-center__body--color | color | #52525b | |
--c2-notification-center__body--font-size | font-size | 13px | |
--c2-notification-center__time--color | color | #52525b | |
--c2-notification-center__time--font-size | font-size | 12px | |
--c2-notification-center__divider--border | border | 1px solid #e4e4e7 | Between the header and the list, and between the groups. |
--c2-notification-center__filter__selected--background-color | color | #f4f4f5 | |
--c2-notification-center__link--color | color | rgb(2, 101, 220) | The Mark all as read and Load more buttons. |
--c2-notification-center__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | |
Text and languages
The text the component shows, in English. It shows another language when the app adds one with addTranslations, under notification-center, and the nearest lang asks for it; any message not translated stays in English. {0}, {1}… stand for the values a message carries. Languages guide.
| Key | English | Values |
|---|---|---|
title | Notifications | — |
filter | Show | — |
all | All | — |
unread | Unread | — |
unreadCount | {0} unread | {0} count |
markAllRead | Mark all as read | — |
markRead | Mark as read | — |
markUnread | Mark as unread | — |
allMarked | All notifications marked as read | — |
unreadItem | Unread: {0} | {0} title |
today | Today | — |
yesterday | Yesterday | — |
empty | No notifications | — |
emptyUnread | You’re all caught up | — |
loadMore | Load more | — |