1.1.1 • Published 3 years ago

@incuca/vue3-toaster v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Vue3 Toaster

Lightweight toast-notification plugin for Vue 3

Installation

npm install @incuca/vue3-toaster

Usage

Import in your main.js

import Toaster from "@incuca/vue3-toaster";

createApp(App)
  .use(Toaster)
  .mount("#app");

Usage in your components with Options API

this.$toast.show(message, { ...options });
this.$toast.success(`Hey! I'm here`);
this.$toast.error(`Hey! I'm here`);
this.$toast.warning(`Hey! I'm here`);
this.$toast.info(`Hey! I'm here`);
// Close all opened toasts after 3000ms
setTimeout(this.$toast.clear, 3000);

Usage with Composition API

import { inject } from "vue";
const toast = inject("toast");
toast.show(message, { ...options });

Available options

The API methods accepts these options:

AttributeTypeDefaultDescription
messageString--Message text/html (required)
typeStringdefaultsuccess, info, warning, error or default
positionStringbottom-righttop, bottom, top-right, bottom-right,top-left or bottom-left
durationNumber/Boolean4000Visibility duration in milliseconds or false that disables duration
dismissibleBooleantrueAllow user close by clicking
onClickFunction--Do something when user clicks
onCloseFunction--Do something after toast gets dismissed
queueBooleanfalseWait for existing to close before showing new
maxToastsNumber/BooleanfalseDefines the max of toasts showed in simultaneous
pauseOnHoverBooleantruePause the timer when mouse hover a toast
useDefaultCssBooleantrueUse default css styles

License

This project is licensed under the MIT License - see the LICENSE file for details.