Skip to content
v0.9.1
Components

Notification center

A bell with an unread count that opens your notifications. Write the list in HTML: Momo keeps the count, the read state and the times up to date.

Bell and panel

Shop admin
JD

Notifications

<div class="cluster justify-between items-center p-3 border rounded bg-surface">
  <b>Shop admin</b>
  <div class="cluster gap-3 items-center">
    <button class="btn btn-icon" type="button" data-momo-popover="inbox" data-momo-align="end" aria-label="Notifications"><i class="mi mi-bell"></i><span class="badge-corner"></span></button>
    <span class="avatar avatar-sm bg-yellow">JD</span>
  </div>
</div>
<div class="popover notifications" id="inbox" data-momo-close-outside aria-label="Notifications">
  <div class="notifications-head">
    <h2 class="notifications-title">Notifications <span class="badge-count" data-momo-unread-count></span></h2>
    <button class="btn btn-sm btn-ghost" type="button" data-momo-mark-all>Mark all as read</button>
    <div class="tabs tabs-boxed tabs-sm tabs-block notifications-filter" role="group" aria-label="Show">
      <button class="tab" type="button" data-momo-notify-filter="all">All</button>
      <button class="tab" type="button" data-momo-notify-filter="unread">Unread</button>
    </div>
  </div>
  <ul class="notifications-list">
    <li class="notifications-group">Today</li>
    <li class="notification is-unread">
      <span class="avatar avatar-sm bg-pink">AK</span>
      <div class="notification-body">
        <p class="notification-text"><a class="notification-link" href="#n-order"><b>Ana Kim</b> commented on order #10421: "Can this ship by Friday?"</a></p>
        <time class="notification-time" data-ago-min="4"></time>
      </div>
    </li>
    <li class="notification is-unread">
      <span class="notification-icon bg-green"><i class="mi mi-credit-card"></i></span>
      <div class="notification-body">
        <p class="notification-text"><b>Payment received</b> $129.00 from Max Ruiz</p>
        <time class="notification-time" data-ago-min="38"></time>
      </div>
    </li>
    <li class="notification is-unread">
      <span class="notification-icon bg-cyan"><i class="mi mi-truck"></i></span>
      <div class="notification-body">
        <p class="notification-text"><b>Order #10418 shipped</b> <span class="notification-sub">Tracking is on its way to the customer.</span></p>
        <time class="notification-time" data-ago-min="125"></time>
      </div>
    </li>
    <li class="notification">
      <span class="avatar avatar-sm bg-violet">LT</span>
      <div class="notification-body">
        <p class="notification-text"><b>Lena Torres</b> mentioned you in Returns</p>
        <time class="notification-time" data-ago-min="300"></time>
      </div>
    </li>
    <li class="notifications-group">Earlier</li>
    <li class="notification">
      <span class="notification-icon bg-red"><i class="mi mi-alert-triangle"></i></span>
      <div class="notification-body">
        <p class="notification-text"><b>Card declined</b> <span class="notification-sub">Order #10402 needs a new payment method.</span></p>
        <time class="notification-time" data-ago-min="1500"></time>
      </div>
    </li>
    <li class="notification">
      <span class="notification-icon bg-yellow"><i class="mi mi-user-plus"></i></span>
      <div class="notification-body">
        <p class="notification-text"><b>Sam Okafor</b> joined your team</p>
        <time class="notification-time" data-ago-min="3000"></time>
      </div>
    </li>
  </ul>
  <p class="notifications-empty" hidden><i class="mi mi-circle-check"></i> You're all caught up.</p>
  <div class="notifications-foot"><a class="btn btn-sm btn-ghost" href="#notify-page">View all notifications</a></div>
</div>

Add from code

Momo.notify() adds one at the top: newest first, under the first group (or the one you name). Add toast: true to also show it as a toast.

<button class="btn" type="button" id="notify-add"><i class="mi mi-plus"></i> New notification</button>
<button class="btn" type="button" id="notify-toast"><i class="mi mi-bell"></i> ...with a toast</button>
<button class="btn btn-ghost" type="button" data-momo-popover="inbox" data-momo-align="start">Open the panel</button>
<script>
  document.getElementById('notify-add').addEventListener('click', function () {
    Momo.notify('#inbox', { title: 'Max Ruiz', text: 'placed order #10422', avatar: 'MR', color: 'cyan', href: '#n-10422' });
  });
  document.getElementById('notify-toast').addEventListener('click', function () {
    Momo.notify('#inbox', { title: 'Low stock', text: 'Momo Mug: 4 left', icon: 'package', color: 'orange', toast: true });
  });
</script>
Momo.notify('#inbox', {
  title: 'Max Ruiz',
  text: 'placed order #10422',
  avatar: 'MR', color: 'cyan',      // or icon: 'package' (with color)
  href: '/orders/10422',
  time: Date.now(),                 // any date; default now
  group: 'Today',                   // optional
  toast: true,                      // also show a toast
});

As a page

Without .popover it is a plain block, for a full "All notifications" page. Add .notifications-page for a card look.

All notifications

  • AK

    Ana Kim commented on order #10421: "Can this ship by Friday?"

  • Payment received $129.00 from Max Ruiz

  • Order #10418 shipped

<div class="notifications notifications-page" id="notify-page" aria-label="All notifications">
  <div class="notifications-head">
    <h2 class="notifications-title">All notifications</h2>
    <button class="btn btn-sm" type="button" data-momo-mark-all>Mark all as read</button>
  </div>
  <ul class="notifications-list">
    <li class="notification is-unread">
      <span class="avatar avatar-sm bg-pink">AK</span>
      <div class="notification-body"><p class="notification-text"><b>Ana Kim</b> commented on order #10421: "Can this ship by Friday?"</p><time class="notification-time" data-ago-min="12"></time></div>
    </li>
    <li class="notification">
      <span class="notification-icon bg-green"><i class="mi mi-credit-card"></i></span>
      <div class="notification-body"><p class="notification-text"><b>Payment received</b> $129.00 from Max Ruiz</p><time class="notification-time" data-ago-min="90"></time></div>
    </li>
    <li class="notification">
      <span class="notification-icon bg-cyan"><i class="mi mi-truck"></i></span>
      <div class="notification-body"><p class="notification-text"><b>Order #10418 shipped</b></p><time class="notification-time" data-ago-min="2900"></time></div>
    </li>
  </ul>
  <p class="notifications-empty" hidden><i class="mi mi-bell-off"></i> Nothing here yet.</p>
</div>
<script>
  document.querySelectorAll('#notify-page time[data-ago-min]').forEach(function (t) { t.setAttribute('datetime', new Date(Date.now() - t.dataset.agoMin * 60000).toISOString()); });
</script>

Two looks

By default it is a list: a light dashed line between items, and unread ones get a violet dot, a faint tint and bold text, while read ones calm down. .notifications-cards makes each item its own rounded card instead.

  • AK

    Ana Kim commented on order #10421

  • Payment received $129.00 from Max Ruiz

  • Order #10418 shipped

<div class="notifications notifications-page notifications-cards" aria-label="Cards look">
  <ul class="notifications-list pt-2">
    <li class="notification is-unread"><span class="avatar avatar-sm bg-pink">AK</span><div class="notification-body"><p class="notification-text"><b>Ana Kim</b> commented on order #10421</p></div></li>
    <li class="notification is-unread"><span class="notification-icon bg-green"><i class="mi mi-credit-card"></i></span><div class="notification-body"><p class="notification-text"><b>Payment received</b> $129.00 from Max Ruiz</p></div></li>
    <li class="notification"><span class="notification-icon bg-cyan"><i class="mi mi-truck"></i></span><div class="notification-body"><p class="notification-text"><b>Order #10418 shipped</b></p></div></li>
  </ul>
</div>

Colors

The unread dot and tint are violet; .notifications-<color> on the panel changes them. Icons take their own color.

  • Low stock Momo Mug: 4 left

  • New message from Ana Kim

  • Payout failed Check your bank details

<div class="notifications notifications-page notifications-orange" aria-label="Store alerts">
  <ul class="notifications-list pt-2">
    <li class="notification is-unread"><span class="notification-icon bg-orange"><i class="mi mi-package"></i></span><div class="notification-body"><p class="notification-text"><b>Low stock</b> Momo Mug: 4 left</p></div></li>
    <li class="notification is-unread"><span class="notification-icon bg-violet"><i class="mi mi-message-circle"></i></span><div class="notification-body"><p class="notification-text"><b>New message</b> from Ana Kim</p></div></li>
    <li class="notification"><span class="notification-icon bg-red"><i class="mi mi-alert-triangle"></i></span><div class="notification-body"><p class="notification-text"><b>Payout failed</b> Check your bank details</p></div></li>
  </ul>
</div>

Events

inbox.addEventListener('momo:read', (e) => save(e.detail.item, e.detail.read));   // item is null for "mark all"
inbox.addEventListener('momo:dismiss', (e) => {                                   // cancelable
  if (!confirm('Dismiss?')) e.preventDefault();
});
inbox.addEventListener('momo:notify', (e) => e.detail.item);                      // after Momo.notify()

Parts

Class / attributeWhat it does
.popover.notifications + data-momo-popoverThe panel and its bell
.badge-cornerA count on the corner of a button or avatar (empty: a dot)
.notifications-head, -title, -filter, -footThe top bar, its title, the All / Unread switch, the bottom bar
.notifications-list > li.notificationOne notification; .is-unread for new ones
li.notifications-groupA heading like "Today"
.notification-icon, .avatarThe round picture on the left
.notification-text, -sub, -time, -linkThe text, a second line, the time, and a link that makes the whole row clickable
[data-momo-unread-count]Shows the unread count (inside the panel, or ="inbox" anywhere)
.notifications-emptyShown when nothing is left to show

Start

OverviewStart Getting startedStart CustomizeStart

Guides

AccessibilityGuides BreakpointsGuides ChangelogGuides Customize componentsGuides JavaScriptGuides MotionGuides OptimizeGuides PhonesGuides RebootGuides Right-to-left (RTL)Guides Stacking orderGuides Using Momo with AIGuides

Foundations

ColorsFoundations TypographyFoundations ProseFoundations Images & figuresFoundations CodeFoundations Lines & shadowsFoundations Dark modeFoundations

Forms

Checkbox & switchForms ComboboxForms Date pickerForms Date rangeForms Fields & labelsForms File uploadForms Floating labelsForms Number stepperForms PasswordForms PIN codeForms RatingForms SelectForms SliderForms Tag inputForms Time pickerForms ValidationForms

Components

AccordionComponents Alert & bannerComponents AvatarComponents BadgeComponents BreadcrumbComponents ButtonComponents Button groupComponents CalendarComponents CardComponents CarouselComponents ChartsComponents ChipsComponents CollapseComponents Command paletteComponents CommentsComponents Confirm dialogsComponents Cookie bannerComponents Data tableComponents Description listComponents Dialog & toastComponents DividerComponents DrawerComponents Dropdown menuComponents Empty stateComponents File managerComponents Filter & sortComponents Gallery & lightboxComponents Inbox & chatComponents Infinite scrollComponents KanbanComponents Keyboard shortcutsComponents List groupComponents MarqueeComponents Media objectComponents Nav overflowComponents Notification centerComponents PaginationComponents ProgressComponents Pull to refreshComponents SkeletonComponents SortableComponents SpinnerComponents Split viewComponents Stat cardComponents Steps & wizardComponents Swipe actionsComponents TableComponents TabsComponents TimelineComponents TogglerComponents Tooltip & popoverComponents TourComponents Tree viewComponents VideoComponents WhiteboardComponents

Layout

Announcement barLayout App shellLayout Back to topLayout Container & sectionLayout ExamplesLayout FooterLayout HeroLayout JumbotronLayout Mega menuLayout NavbarLayout Site sidebarLayout

Sections

Bento gridSections Blog cardsSections Call to actionSections Contact & newsletterSections FAQSections FeaturesSections Logo cloudSections PricingSections TeamSections TestimonialsSections

Utilities

OverviewUtilities State variantsUtilities Display & flexUtilities Grid & gapUtilities SpacingUtilities SizingUtilities TextUtilities Links & color strengthUtilities Position & overflowUtilities BackgroundsUtilities Borders & effectsUtilities Transforms & filtersUtilities InteractionsUtilities

Helpers

Fixed, sticky & frostedHelpers Hover & focusHelpers Hover revealHelpers Icon linkHelpers PrintHelpers Relative timeHelpers Screen reader textHelpers Scroll inHelpers ScrollspyHelpers Share buttonHelpers Skip linkHelpers StacksHelpers Stretched linkHelpers Theme toggleHelpers Truncated textHelpers

Page patterns

404 pagePage patterns Coming soonPage patterns Login & registerPage patterns SettingsPage patterns ProfilePage patterns CRM contactsPage patterns ProjectsPage patterns File manager pagePage patterns Billing & plansPage patterns Help centerPage patterns Mobile app screensPage patterns
↑ ↓ moveEnter openEsc close