Skip to main content
Urbicon UI
source

NotificationCenter

A notification list with per-item mark-as-read and delete, an empty state, and each entry rendered as a clickable card with its timestamp.

01 Usage

Basic

Notifications

<script lang="ts">
  import { NotificationCenter } from '@urbicon-ui/auth';

  const demoNotifications = [
    {
      id: '1',
      userId: 'demo',
      title: 'Welcome!',
      body: 'Your account has been created.',
      type: 'system',
      typeKey: 'welcome',
      url: null,
      icon: null,
      createdAt: new Date(Date.now() - 5 * 60000),
      readAt: null
    },
    {
      id: '2',
      userId: 'demo',
      title: 'New feature available',
      body: 'Passkey login is now supported.',
      type: 'system',
      typeKey: 'feature',
      url: null,
      icon: null,
      createdAt: new Date(Date.now() - 3600000),
      readAt: new Date()
    }
  ];
</script>

<NotificationCenter
  notifications={demoNotifications}
  onMarkAsRead={(id) => console.log('Mark as read:', id)}
  onMarkAllAsRead={() => console.log('Mark all as read')}
  onDelete={(id) => console.log('Delete:', id)}
/>

02 Accessibility

Each notification is a button

The body of every item is a <button>, not a click handler on the <li>, so it is reachable with Tab and activatable with Enter or Space without any extra ARIA.

Unread rows say so

The unread dot is aria-hidden="true" — it is decoration — and the localized "Unread" sits beside it as visually hidden text inside the row's button, ahead of the title, so the button's accessible name begins with it — "Unread Deploy finished …" where a sighted user sees the dot. The data-unread attribute stays for CSS, and the hidden word survives unstyled: it is the state, not a default look. A custom item snippet replaces the whole row, so the marker is yours to render there.

The delete button names its notification

It renders a × glyph, so the name comes from an aria-label: the localized "Delete" with the notification's title appended — "Delete — Deploy finished". Ten notifications are ten distinguishable buttons rather than ten identical ones, and the name still begins with the visible word, so voice control ("click Delete") keeps working.

The list is announced, and the timestamp is machine-readable

Items sit in a <ul>, so the count is announced before the contents. The relative age renders in a <time> element whose datetime attribute carries the ISO instant behind the rounded label, so "1h ago" has an exact time attached to it. A record whose timestamp does not parse drops the attribute rather than the row.

03 API Reference

11 props 1 required
Prop
Type
Default
Description

04 Types

Local type definitions used by this component.

4 types
Name
Kind
Category
Used by
Description

05 Installation

Import

import { NotificationCenter } from '@urbicon-ui/auth';