vue3-toast-single

A toast plugin for vue3, support composition API.
4,776 13
Install
npm install vue3-toast-single
Latest Version:1.0.5
Vue:3
License:MIT
Last Updated:Aug 17, 2023
Links: GitHub  ·  npm
Maintainer: webkong

vue3-toast-single

Vue 3.x

A toast plugin for vue3. Support composition API.

See the example.

Note:

Issue/PR is welcomed, I'll response as soon as possible.

If you like this plugin, can give a star.

Usage

install

npm install vue3-toast-single --save

Quickstart

// import 
import Toast from 'vue3-toast-single'
import 'vue3-toast-single/dist/toast.css'

const app = createApp(App);

app.use(Toast, { verticalPosition: "bottom", duration: 1500 });
app.mount("#app");

// Usage

{
  // ....
 methods: {
    clickHandler() {
      this.$wkToast('A toast.');
    },
  },
  // ...
}

{
  // ...
  setup() {
        const toast = Vue.inject("WKToast");
        const clickHandler = () => {
          toast("A toast.");
        };
        return {
          clickHandler,
        };
      },
  // ...
}

Config

toast or $wkToast takes 2 parameter: (message, [options])

Options
Parameter Type Default Description
className string, array Self-defined class names to pass through. There are 3 pre-defined classes: wk-info, wk-warn,wk-alert, to toast with different background color
horizontalPosition string center Position horizontal of toast. There are 3 pre-defined positions: left, right and center
verticalPosition string bottom Position vertical of toast. There are 2 pre-defined positions: top and bottom
duration number 3000 The duration one toast will last, in milliseconds
closeable boolean false true or false. If true, the toast can be closed manually
transition string slide-down Built-in transitions: fade, slide-[up/down/left/right]. See also Transitions
Styling

Besides minimum styling, vue3-toast-single try not to be opinionated about the appearance. It is a simply a div(class="wk-wrapper") wrapped a span(class="wk-content"). Apply your css freely with them or with your own classes passed in as className.

config example
// global
app.use(Toast, { verticalPosition: "bottom", duration: 1500 });

// local
this.$wkToast('A toast', {
  className: ['my-toast', 'toast-warning'],
  horizontalPosition: 'right',
  verticalPosition: 'top',
  duration: 3000,
  transition: 'transition'
})
TODO
  • Add a queue mode
  • emoji

License

MIT

Related Packages

vue-easy-toast

A toast plugin for vue/vue2

9,314 119
vue-json-tree-view

a JSON Tree View Component in Vue.js

380,792 473
@v-c/picker

picker ui component for vue

57,185 32
vue-frame-crm

vue components for crm system

15,005
kokk

A beautiful way to create a documentation from markdown, and insert a vue compon...

10,142 49

Version History

Version Released Vue License
1.0.5 ^3.0.0 MIT
1.0.2 ^3.0.0 MIT
1.0.1 ^3.0.0 MIT
0.0.6 ^3.0.0 MIT
0.0.5 ^3.0.0 MIT