Skip to content

Notification

Built on top of Radix Vue's Toast component, providing flexible notification features. Supports multiple variants, position configuration, auto-dismissal, swipe-to-dismiss, and more.

Based on BrConfigProvider for global theme configuration, supporting both component and function call styles.

Basic Usage

The simplest notification.

Example

Variants

Supports 6 variants: default, primary, success, error, warning, info.

Example

Positions and Duration

You can configure the popup position (top-left/top-right/bottom-left/bottom-right) and auto-dismiss duration via BrNotificationProvider.

Select Position
Example

With Action

You can add action buttons to handle user interactions.

Example

API

BrNotification

PropertyTypeDefaultDescription
titlestring-The title of the notification
descriptionstring-The description of the notification
variant'default' | 'primary' | 'success' | 'error' | 'warning' | 'info''default'The variant of the notification
durationnumber5000The time in milliseconds before auto-dismissal
dismissiblebooleantrueWhether to show the dismiss button
actionNotificationAction-Configuration for the action button
iconComponent-Custom icon component

BrNotificationProvider

PropertyTypeDefaultDescription
position'top-left' | 'top-right' | 'bottom-left' | 'bottom-right''bottom-right'Position of the notifications
durationnumber5000Default auto-dismissal time
swipeDirection'up' | 'down' | 'left' | 'right''right'Direction for swipe-to-dismiss
swipeThresholdnumber50Threshold for swipe-to-dismiss

useNotification

MethodParametersReturn TypeDescription
toastprops: Omit<NotificationProps, 'id'>{ id, dismiss, update }Creates and shows a notification
dismissid?: string-Dismisses a notification by id. If no id is provided, dismisses all
toasts-Ref<NotificationProps[]>Reactive list of all current notifications

Theming

Global Configuration (BrConfigProvider)

You can configure global style variables for Notification via BrConfigProvider.

vue
<template>
  <BrConfigProvider :theme="themeConfig">
    <BrNotificationProvider>
      <App />
    </BrNotificationProvider>
  </BrConfigProvider>
</template>

<script setup>
const themeConfig = {
  radius: 0.5,
  primary: '#3b82f6',
  success: '#22c55e',
  error: '#ef4444',
  warning: '#f59e0b',
  info: '#3b82f6',
  zNotification: 200, // Custom z-index
}
</script>

TailwindCSS Override

You can override styles directly via the class property.

ts
toast({
  title: 'Custom Style',
  class: 'bg-purple-500 text-white border-none',
})