Notifications

Notifications show short updates about app processes at the on the screen.

import { NotificationCenter, toaster } from '@cerberus/react'

Usage

The NotificationCenter component is used to manage notifications in your application. It works together with the toaster object to display notifications.

Types

Just update the options.types to change the theme of the notification. The options are info, success, warning, error, and loading.

Badges

Badges can be used to show the number of notifications on any trigger by using the data-notify and data-notify-count attributes.

Small IconButton
Large IconButton

Primitives

You can utilize the primitive components to customize the toast notification.

ComponentDescription
NotificationProviderThe context provider for the toast notifications.
NotificationRootThe context provider for the toast parts.
NotificationHeadingThe title heading of the toast.
NotificationDescriptionThe description of the toast.
NotificationCloseTriggerThe close button of the toast.
NotificationActionTriggerThe action button of the toast.

API

Props

The NotificationCenter component is an abstraction of the primitives and doesn't accept any props.

toaster

The toaster object is used to create notifications and accepts the following options:

NameTypeDescription
typestringThe type of notification. Options are info, success, warning, error, and loading.
titlestringThe title of the notification.
descriptionstringThe description of the notification.
actionToasterActionThe action object of the notification.
durationnumberA custom duration of the notification.
onClosefunctionThe callback function when the notification is closed.

ToasterAction

The ToasterAction object is used to create an action button for the notification and accepts the following options:

NameTypeDescription
labelstringThe label of the action button.
onClickfunctionThe callback function when the action button is clicked.

Parts

The NotificationParts API is an Object containing the full family of components.

NameDescription
RootThe NotificationRoot component which is the Provider for the toast.
HeadingThe NotificationHeading component which displays the heading title for the toast.
DescriptionThe NotificationDescription component which displays the description for the toast.
CloseTriggerThe NotificationCloseTrigger component which displays the close button for the toast.
ActionTriggerThe NotificationActionTrigger component which displays the action button for the toast.