Skip to content
LIBRARYFeedbackUpdated

NotificationCenter ​

RC.12.1

Included in RC.12.1 for Vue + Vite, Nuxt and NativeScript.

Web preview
Open example ↗
vue
<MNotificationCenter
  v-model="notifications"
  v-model:filter="filter"
  label="Inbox"
  @action="openNotification"
/>
PropTypeDefaultContract
modelValuereadonly MavisNotification[]requiredUnique id/title, optional description/group/time/read/disabled/dismissible/actionLabel. Up to 1000.
filterall | unreadallControlled filter; hidden notifications remain in the model.
animated / disabledbooleantrue / falseJolt collection layout and editing lock.
label / idstringrequired / optionalAccessible component name and optional stable ID.

Grouped messages, unread count, read/unread, mark-all-read, dismissal and an application action share one controlled model. Unknown metadata is preserved. Disabled entries are untouched; dismissible=false prevents removal. When an action removes the focused message, focus returns to the filter. Titles, descriptions and optional time strings are text, never HTML. All toolbar/action labels are localizable. The app owns transport, authorization, persistence and action handling; this component does not request OS push permissions, subscribe to a service or fetch notifications.

To populate the inbox from mobile push events, see Push notifications with Notti.

update:modelValue → MavisNotification[]; update:filter → all | unread; action → notification ID.

A bell beside the title swings when the unread count rises, and the count pill bumps. New messages arrive from above, dismissed ones slide out while the rest close the gap, and each unread message carries a dot that pops in and, after Mark all as read, goes out one after another. The count is read as text; the bell and dots are decoration.

Motion uses Jolt and respects reduced motion. Use :animated="false" for static presentation.

vue
<script setup lang="ts">
import { computed, ref, onBeforeUnmount } from 'vue'
import { useCatalogLocale } from '../locale'
const props = defineProps<{ lang?: 'en' | 'pt' }>()
const { locale } = useCatalogLocale(() => props.lang)
const t = (en: string, pt: string) => ((props.lang ?? locale.value) === 'pt' ? pt : en)
const animated = ref(true)

import type { MavisNotification } from '@getcortexlabs/mavis-core'
const filter = ref<'all' | 'unread'>('all'),
  action = ref('')
const items = ref<MavisNotification[]>([
  {
    id: 'edition',
    title: 'The autumn edition is ready',
    description: 'Your stories, photographs and small discoveries. All in one place.',
    group: 'Today',
    time: '09:41',
    actionLabel: 'Open edition',
    read: false,
  },
  {
    id: 'feedback',
    title: 'A fresh pair of eyes',
    description: 'Mara left a thoughtful note on your latest collection.',
    group: 'Today',
    time: '08:20',
    read: false,
  },
  {
    id: 'welcome',
    title: 'A good beginning',
    description: 'Your studio is ready. Make something worth keeping.',
    group: 'Earlier',
    time: 'Yesterday',
    read: true,
    dismissible: false,
  },
])
let serial = 0
function add() {
  items.value = [
    {
      id: 'new-' + serial++,
      title: 'A new invitation',
      description: 'A little space for something unexpected.',
      group: 'Today',
      read: false,
    },
    ...items.value,
  ]
}
</script>
<template>
  <MColumn gap="lg">
    <MText text="THE FIELD GUIDE / 06" variant="overline" tone="primary" />
    <MText
      :text="t('A little less noise. More meaning.', 'Menos ruído. Mais significado.')"
      variant="title"
    />
    <MNotificationCenter
      id="studio-notifications"
      v-model="items"
      v-model:filter="filter"
      :animated="animated"
      :label="t('Your studio inbox', 'A caixa de entrada do estúdio')"
      :allLabel="t('All', 'Todas')"
      :unreadLabel="t('Unread', 'Não lidas')"
      :readLabel="t('Mark as read', 'Marcar como lida')"
      :unreadActionLabel="t('Mark as unread', 'Marcar como não lida')"
      :readAllLabel="t('Mark all as read', 'Marcar todas como lidas')"
      :dismissLabel="t('Dismiss', 'Dispensar')"
      :emptyLabel="
        t('A quiet moment. You are all caught up.', 'Um momento tranquilo. Tudo em dia.')
      "
      @action="action = $event"
    />
    <MButton
      :text="t('Receive an invitation', 'Receber um convite')"
      variant="secondary"
      @click="add"
    />
    <MText
      id="notification-state"
      :text="items.map((x) => x.id + ':' + !!x.read).join(',')"
      variant="caption"
      tone="muted"
    /><MText id="notification-action" :text="action" variant="caption" />

    <MSwitch v-model="animated" :label="t('Animate changes', 'Animar mudanças')" />
  </MColumn>
</template>

Desktop ​

On the Mac and on Windows the list, groups, filters and actions work through native buttons, and the keyboard moves to the Unread filter when the pressed control disappears. animated is accepted and has no effect. See Desktop components.

Components for NativeScript and Web. Starting with Vue.