DocsBlog

Get Started

Components

Data Grid

Signals

Styling

Theming

↑↓Navigate
↵Select
EscClose
  • 1.8.0

  • Day

    Night

    Preview

    Switch mode
  • cerberus

    acheron

    elysium

    oceanus

Get Started
Components
Data Grid
Signals
Styling
Theming

Concepts

OverviewCompositionCerberus ContextTesting

Layout

Aspect RatioBleedBoxCenterContainerContainer QueryDividerFlexFloatGridGroupLink OverlayScrollableStackWrap

Components

AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTA ModalDate PickerDialogFieldFieldsetFile UploaderIconButtonInputLoading StatesMarqueeMenuNotificationsNumber InputPaginationPin InputPopoverProgress IndicatorsPrompt ModalRadioRatingSelectSliderSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

Utilities

Client OnlyDownload TriggerEnvironmentFeature FlagsFocus TrapForFormat ByteFormat NumberFormat Relative TimeFormat Relative TimeFrameHighlightJSON Tree ViewLocalePortalPresenceShowSwapsplitPropsTheme

Notifications

The Notification component is used to display notifications in your application.

  • npm
  • source
  • recipe
  • Ark
View as Markdown
Open this page in Markdown
Anthropic
Open in Claude
Ask questions about this page
OpenAI
Open in ChatGPT
Ask questions about this page

Import

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.

Loading example...

Types

Update the options.types of the toaster.create function to change the theme of the notification.

The options are info, success, warning, danger, and loading.

Subtle Notifications

Subtle notifications are a less intrusive way to inform users about events or updates. They typically have a softer appearance and may not require immediate user action.

Use the usage: 'subtle' option to create a subtle notification.

Loading example...

Custom Configuration

You can customize the notification behavior by calling the createToaster function. This allows you to create a new toaster instance with your desired configuration.

You can either use it as a local one-off or pass it into the NotificationCenter component for a global change.

Loading example...

Badges

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

Note

Combine this with the `formatNotifyCount` helper that will restrict the count to 3 digits.

Loading example...

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.
usage'subtle' | 'default'The visual type of the notification. The default option is default.

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.

Note

It is best to only use the NotificationParts if you are building a custom solution. Importing Object based components will ship every property it includes into your bundle, regardless if you use it or not.

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.

On this page

  • Import
  • Usage
  • Types
  • Subtle Notifications
  • Custom Configuration
  • Badges
  • Primitives
  • API
    • Props
    • toaster
    • ToasterAction
    • Parts
Edit this page on Github
Small IconButton
Large IconButton