• Stars
    star
    615
  • Rank 72,947 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 6 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Yet another toast notification plugin for Vue.js 🌷

Vue Toast Notification

downloads js-delivr npm-version github-tag build license TypeScript

Yet another Vue.js Toast notification plugin.

Demo or JSFiddle

Version matrix

Vue.js version Package version Branch
2.x 1.x 1.x
3.x 3.x main

Installation

npm install vue-toast-notification@^3

Usage

Plugin usage

Install the plugin

import {createApp} from 'vue';
import ToastPlugin from 'vue-toast-notification';
// Import one of the available themes
//import 'vue-toast-notification/dist/theme-default.css';
import 'vue-toast-notification/dist/theme-bootstrap.css';

const app = createApp({});
app.use(ToastPlugin);
app.mount('#app');

Then use in your components

export default {
    mounted() {
        let instance = this.$toast.open('You did it!');

        // Force dismiss specific toast
        instance.dismiss();

        // Dismiss all opened toast immediately
        this.$toast.clear();
    }
}

Composition API usage

import {useToast} from 'vue-toast-notification';
import 'vue-toast-notification/dist/theme-sugar.css';

const $toast = useToast();
let instance = $toast.success('You did it!');

// Force dismiss specific toast
instance.dismiss();

// Dismiss all opened toast immediately
$toast.clear();

Available options

The API methods accepts these options:

Attribute Type Default Description
message String -- Message text/html (required)
type String success One of success, info, warning, error, default
position String bottom-right One of top, bottom, top-right, bottom-right,top-left, bottom-left
duration Number 3000 Visibility duration in milliseconds, set to 0 to keep toast visible
dismissible Boolean true Allow user dismiss by clicking
onClick Function -- Do something when user clicks
onDismiss Function -- Do something after toast gets dismissed
queue Boolean false Wait for existing to dismiss before showing new
pauseOnHover Boolean true Pause the timer when mouse on over a toast

API methods

this.$toast.open(options)

This is generic method, you can use this method to make any kind of toast.

// Can accept a message as string and apply rest of options from defaults
this.$toast.open('Howdy!');

// Can accept an Object of options
this.$toast.open({
    message: 'Something went wrong!',
    type: 'error',
    // all of other options may go here
});

this.$toast.success(message,?options)

There are some proxy methods to make it more readable.

this.$toast.success('Profile saved.', {
    // optional options Object
})

this.$toast.error(message,?options)

this.$toast.warning(message,?options)

this.$toast.info(message,?options)

this.$toast.default(message,?options)

Global options

You can set options for all the instances during plugin initialization

app.use(VueToast, {
    // One of the options
    position: 'top'
})

Further you can override option when creating new instances

this.$toast.success('Order placed.', {
    // override the global option
    position: 'bottom'
})

Install in non-module environments (without webpack)

<!-- Vue.js -->
<script src="https://cdn.jsdelivr.net/npm/vue@3"></script>
<!-- Lastly add this package -->
<script src="https://cdn.jsdelivr.net/npm/vue-toast-notification@3"></script>
<link href="https://cdn.jsdelivr.net/npm/vue-toast-notification@3/dist/theme-sugar.css" rel="stylesheet">
<!-- Init the plugin -->
<script>
    const app = Vue.createApp({});
    app.use(VueToast.ToastPlugin);
    app.mount('#app');
</script>

Run examples on your localhost

  • Clone this repo
  • Make sure you have node-js >=18.16 and pnpm >=8.3 pre-installed
  • Install dependencies - pnpm install
  • Run webpack dev server - pnpm start
  • This should open the demo page in your default web browser

Acknowledgements

License

MIT License

More Repositories

1

vue-loading-overlay

Vue.js component for full screen loading indicator 🌀
JavaScript
1,219
star
2

vue-flatpickr-component

Vue.js component for Flatpickr datetime picker 📆
TypeScript
964
star
3

vue-cleave-component

Vue.js component for Cleave.js input mask library ⌨️
JavaScript
281
star
4

vue-trumbowyg

Vue.js component for Trumbowyg WYSIWYG editor 📝
JavaScript
236
star
5

vue-bootstrap-datetimepicker

Vue.js component for eonasdan bootstrap datetimepicker
JavaScript
224
star
6

google-chat-electron

An unofficial desktop app for Google Chat :electron:
TypeScript
158
star
7

vue-web-storage

Vue.js plugin for local storage and session storage (1.8 kb min+gz) 💾
TypeScript
85
star
8

fcm-notification-channel

All in One Firebase push notification channel for Laravel 🔔
PHP
68
star
9

laravel-eloquent-relationships

Add some more eloquent relationships to Laravel php framework. 👫
PHP
57
star
10

phpunit-travis-ci-coverage-example

phpUnit Testing on Travis-CI with Code Coverage on CodeCov
PHP
28
star
11

laravel-mix-auto-extract

[DEPRECATED] Laravel Mix v2/3 plugin to auto extract vendor js
JavaScript
25
star
12

laravel-ses-webhooks

AWS SES Webhooks client for Laravel 📬
PHP
22
star
13

laravel-socialite-multiple-providers-example

Laravel socialite with multiple providers example
PHP
20
star
14

vue-jquery-mask

Vue.js component for jQuery mask plugin
JavaScript
20
star
15

vue-lunch-order-app

Lunch order app, built with Vue.js v2 and Google Spreadsheet
JavaScript
17
star
16

laravel-paypal-webhooks

Handle PayPal webhooks in Laravel 💵
PHP
16
star
17

bandwidth-notification-channel

Bandwidth SMS notification channel for Laravel php framework 📩
PHP
12
star
18

wp-google-map

Google Map Plugin for WordPress
PHP
11
star
19

laravel-bundler

Modern asset building tool for Laravel framework with better defaults. 📦
JavaScript
11
star
20

codeception-travis-ci-example

[READ-ONLY] Codeception Acceptance Testing on Travis-CI
PHP
9
star
21

wp-prism-js

Prism Syntax Highlighter Plugin for WordPress
PHP
7
star
22

vue-bugsnag

[DEPRECATED] Vue.js plugin for Bugsnag js v3.x error reporting
JavaScript
6
star
23

vue-progress-indicator

Vue.js component for progress indicator
JavaScript
5
star
24

electron-update-notifier

Update notifier for Electron apps 🔔
TypeScript
5
star
25

laravel-form-validation

Yet another form validation (JS) helper for Laravel. ☂️
TypeScript
5
star
26

laravel-blogger-api-example

Laravel demo blog REST api 🧙‍♂️
PHP
4
star
27

laravel-stripe-exceptions

Handle Stripe exceptions gracefully in Laravel php framework. ☄️
PHP
4
star
28

node-webkit-angular-starter-kit

[READ-ONLY] A node-webkit and Angular js based desktop app
JavaScript
3
star
29

laravel-alert

A Bootstrap alert helper for Laravel php framework 🥭
PHP
3
star
30

laravel-lunch-order-app

[WIP] Lunch order app built with Laravel
PHP
2
star
31

laravel-vonage-inbound-sms

Vonage Inbound SMS Webhooks Client for Laravel ☎️
PHP
2
star
32

wp-google-analytics

Google Analytics Plugin for WordPress
PHP
2
star
33

gulp-3-browsersync-scss-seed

[READ-ONLY] Front-end development starter kit for beginners
JavaScript
2
star
34

vue-php-demo-2021

Sample app to demo vue.js with php
PHP
2
star
35

laravel-otp

One time password (OTP) generator and verifier for Laravel 📲
PHP
2
star
36

ankurk91.github.io

Ankur Kumar's GitHub Profile 🎉
HTML
1
star
37

ankurk91

The README repo 😉
1
star
38

laravel-passport-socialite-example

Laravel passport with socialite
PHP
1
star
39

laravel-shopping-cart

Shopping cart manager for Laravel. 🛒
PHP
1
star
40

wp-tabs-example

WordPress plugin to demonstrate how to use in-built tabs on plugin options page
PHP
1
star
41

wp-lazy-intercom

WordPress plugin to lazy load Intercom widget
PHP
1
star
42

wp-screen-options-example

WordPress plugin to demonstrate screen options usage in your plugin options page
PHP
1
star