Vue Bootstrap Notifications
Vue Notifications - Bootstrap 4 & Material Design
Note: This documentation is for an older version of Bootstrap (v.4). A
newer version is available for Bootstrap 5. We recommend migrating to the latest version of our product - Material Design for
Bootstrap 5.
Go to docs v.5
Vue Bootstrap notifications are feedback messages which are displayed after specific actions preceded by the user. Length of the text is not limited.
With the right use of colors, they add some emotional weight to our information, ranging from a simple warning to critical system failure or from an operation success to a neutral information.
Material example MDB Pro component
Bootstrap example
Stacking
When you have multiple toasts, we default to vertiaclly stacking them in a readable manner.
Placement
Use the css position
property on wrapping components to controll placement of your
notification.
Custom icons
Use icon
property to set custom icon from the icons list.
Time display
To hide time count set the time
property to false
.
You can overwrite the default starting point for time count by passing Date Object to the
received
property.
Vue Material Notifications - API
In this section you will find information about how exactly to use notifications.
Basic usage
Toastr-like Notify feature is rather special among the general components population, as it is rather a funtionality (a plugin, if you may), rather than the template markup.
It means that to display a notification you do not have to import and position it yourself. Rather, it works as a
plugin, meaning that all Vue instances have the ability to call a notification. Let's start off by adding this
ability to their arsenal. To make notification available to the all (aka. to add it as a plugin), import it into
your root Vue instance and make Vue .use()
Notify
. If you are using
vue-cli
,
the root Vue instance is accessible in the /src/main.js
file. Make sure it looks something like this:
Voilà! Now, notifications are available everywhere!
Calling a notification
Generally, a notification pops up once we call one of the $notify
global property methods, namely
With no parameters, calling it will show a basic notification of designated color and with no content in its default position, being top center.
Customization
To give a notification some character, pass in a configuration object as the function parameter. Below are it's available properties:
Name | Type | Default | Description |
---|---|---|---|
title |
String | '' | Title, if any |
message |
String | '' | Text within the notification's "paragraph" |
closeButton |
Boolean | true | Should the close button ("x") be there? |
progressBar |
Boolean | false | Sets whether a progress bar should mark notification's timeout |
position |
String | top right | Available values: 'top right', 'bottom right', 'bottom left', 'top left', 'top center', 'bottom center', 'top full width', 'bottom full width' |
showMethod |
String | fadeIn | Animations class name for shown, default as fadeIn |
hideMethod |
String | fadeOut | Animations class name for hide, default as fadeOut |
showDuration |
Number | 1000 | Duration of show animation in ms |
hideDuration |
Number | 1000 | Duration of hide animation in ms |
delay |
Number | 0 (no dalay) | Helps to set up a delay on when the notification should appear in ms |
timeOut |
Number | 1500 | Sets duration of time the notification is out there in ms |
color |
String | successColor | Overwrite the default color of a notification |
A full exemplification of an this.$notify
with a configuration object inside some
component's method:
Closing notifications
Notifications disappear after a time-out, which covers most use cases. To dismiss a notification, an user may click the close button, which is provided by default. Lastly, application's logic can clear all the notifications programmatically, calling
this.$notify.removeAll()
Vue Bootstrap Notifications - API
In this section you will find information about how exactly to use notifications.
Basic example
Properties
To give a notification some character, pass in a configuration object as the function parameter. Below are it's available properties:
Name | Type | Default | Description |
---|---|---|---|
title |
String | '' | Title |
message |
String | '' | Text within the notification's "paragraph" |
icon |
String | 'square' | Sets a custom icon. |
iconSize |
String | 'lg' | Changes a size of an icon. |
iconColor |
String | 'primary' | Changes a color of an icon. |
show |
Boolean | false | Controls displaying of a notification. |
time |
Boolean | true | Controls displaying of a time counter. |
received |
Date | Sets a starting points for a time counter. |