All Projects → Daniel-Knights → vue-dk-toast

Daniel-Knights / vue-dk-toast

Licence: other
Lightweight toast-notification plugin for Vue 3 🍞

Programming Languages

typescript
32286 projects
Vue
7211 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to vue-dk-toast

Jquery Toast Plugin
Highly customizable jquery plugin to show toast messages
Stars: ✭ 1,237 (+5278.26%)
Mutual labels:  notifications, toast
React Toast Notifications
🍞 A toast notification system for react
Stars: ✭ 2,103 (+9043.48%)
Mutual labels:  notifications, toast
Svelte Notifications
Svelte toast notifications component that can be used in any JS application
Stars: ✭ 146 (+534.78%)
Mutual labels:  notifications, toast
Laravel Notify
Flexible Flash notifications for Laravel
Stars: ✭ 787 (+3321.74%)
Mutual labels:  notifications, toast
Sweetalert2
A beautiful, responsive, highly customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes. Zero dependencies.
Stars: ✭ 13,929 (+60460.87%)
Mutual labels:  notifications, toast
Burnttoast
Module for creating and displaying Toast Notifications on Microsoft Windows 10.
Stars: ✭ 796 (+3360.87%)
Mutual labels:  notifications, toast
Notistack
Highly customizable notification snackbars (toasts) that can be stacked on top of each other
Stars: ✭ 2,562 (+11039.13%)
Mutual labels:  notifications, toast
Gsmessages
A simple style messages/notifications, in Swift.
Stars: ✭ 595 (+2486.96%)
Mutual labels:  notifications, toast
React Notify Toast
Toast notifications for React.js
Stars: ✭ 176 (+665.22%)
Mutual labels:  notifications, toast
Angular Notifier
A well designed, fully animated, highly customizable, and easy-to-use notification library for your Angular application.
Stars: ✭ 175 (+660.87%)
Mutual labels:  notifications, toast
Notie
🔔 a clean and simple notification, input, and selection suite for javascript, with no dependencies
Stars: ✭ 6,170 (+26726.09%)
Mutual labels:  notifications, toast
Toasted Notes
simple, flexible toast notifications for react
Stars: ✭ 241 (+947.83%)
Mutual labels:  notifications, toast
Vue Snotify
Vuejs 2 Notification Center
Stars: ✭ 755 (+3182.61%)
Mutual labels:  notifications, toast
Reapop
📮 A simple and customizable React notifications system
Stars: ✭ 1,155 (+4921.74%)
Mutual labels:  notifications, toast
Vue Toastification
Vue notifications made easy!
Stars: ✭ 747 (+3147.83%)
Mutual labels:  notifications, toast
Notyf
👻 A minimalistic, responsive, vanilla JavaScript library to show toast notifications.
Stars: ✭ 2,093 (+9000%)
Mutual labels:  notifications, toast
Cogo Toast
Beautiful, Zero Configuration, Toast Messages for React. Only ~ 4kb gzip, with styles and icons
Stars: ✭ 557 (+2321.74%)
Mutual labels:  notifications, toast
Toastify Js
Pure JavaScript library for better notification messages
Stars: ✭ 570 (+2378.26%)
Mutual labels:  notifications, toast
Notiflix
Notiflix is a JavaScript library for client-side non-blocking notifications, popup boxes, loading indicators, and more that makes your web projects much better.
Stars: ✭ 172 (+647.83%)
Mutual labels:  notifications, toast
Overlay support
a flutter toast and notification library
Stars: ✭ 232 (+908.7%)
Mutual labels:  notifications, toast

vue-dk-toast

Lightweight toast-notification plugin for Vue 3 🍞

npm vue

  • Lightweight ☁️
  • Customizable 🧰
  • Easy to use 🥷
  • Mobile-friendly 📱
  • Built-in TypeScript support 🔒
  • A11y compliant 🧑‍🦯

Demo
CodePen Demo

      ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
    ▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒
  ▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒
▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒
▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒
▒▒▒▒▒▒░░░░░░░░░░██░░░░░░░░░░░░░░██░░░░░░▒▒
  ▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒
    ▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒
    ▒▒▒▒▒▒░░░░░░░░░░░░██████░░░░░░░░▒▒
    ▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒
    ██▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒██
  ██▒▒▒▒▒▒░░░░░░░░▒▒░░░░░░░░░░░░░░░░▒▒  ██
██  ▒▒▒▒▒▒░░░░░░░░░░░░░░░░▒▒░░░░░░░░▒▒  ██
██  ▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒  ██
██  ▒▒▒▒▒▒░░▒▒░░░░░░░░░░░░░░░░░░▒▒░░▒▒  ██
██  ▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒  ██
██  ▒▒▒▒▒▒░░░░░░░░░░░░▒▒░░░░░░░░░░░░▒▒  ██
██  ▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒  ██
    ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
            ██                ██
            ██                ██
            ██                ██
            ██                ██
            ████              ████

Install

CLI

npm i vue-dk-toast

or...

yarn add vue-dk-toast

CDN

<script src="https://unpkg.com/vue-dk-toast"></script>

It's recommended you use a specific version number to guard against breaking changes and load the script faster:

<script src="https://unpkg.com/[email protected]"></script>

Import

CLI

import { createApp } from 'vue';
import DKToast from 'vue-dk-toast';
import App from './App.vue';

createApp(App).use(DKToast).mount('#app');

CDN

const app = Vue.createApp({});

app.use(DKToast);
app.mount('#app');

Usage

Options API:

this.$toast('Simple!');

or...

@click="$toast('Simple!')"

Composition API:

<script>
  import { inject } from 'vue';

  export default {
    setup() {
      const toast = inject('$toast');

      toast('Simple!');
    },
  };
</script>

Options

Option Type Default Description
class String | String[] None Custom CSS class to be added to every toast (alongside .dk__toast). Must be an array of strings for multiple classes.
disableClick Boolean false Disable toast removal on click.
duration Number 5000 Milliseconds before hiding toast.
pauseOnHover Boolean true Pause toast duration on mouseover, resume on mouseout.
max Number None Max number of toasts allowed on the page at any one time. Removes oldest existing toast first.
positionX String right Position of container on the X axis - 'left', 'right' or 'center'.
positionY String bottom Position of container on the Y axis - 'top', or 'bottom'.
styles Object None CSS key/value pairs - supports vendor prefixes.

EXAMPLE:

createApp(App)
  .use(DKToast, {
    duration: 5000,
    pauseOnHover: true,
    positionY: 'bottom', // 'top' or 'bottom'
    positionX: 'right', // 'left', 'right' or 'center'
    disableClick: false,
    styles: {
      color: '#000',
      backgroundColor: '#fff',
      // Vendor prefixes also supported
    },
    class: 'custom-class', // Added to each toast,
    max: 10,
  })
  .mount('#app');

Local Options

Local options override global options where duplicate.

Option Type Default Description
class String | String[] None CSS class to be added to this toast only (alongside .dk__toast and any globally set custom-class).
disableClick Boolean false Disable individual toast removal on click.
duration Number 5000 Milliseconds before hiding toast.
pauseOnHover Boolean true Pause toast duration on mouseover, resume on mouseout.
link { href: string, targetBlank?: boolean } none Turns the toast into an <a> element which has a href of the one provided and optional target="_blank".
positionX String right Position of container on the X axis - 'left', 'right' or 'center'.
positionY String bottom Position of container on the Y axis - 'top', or 'bottom'.
slotLeft String None Any valid HTML as a string. Displays left of text.
slotRight String None Any valid HTML as a string. Displays right of text.
styles Object None CSS key/value pairs. Supports vendor prefixes.
type String None Default helper class - success, error or passive.

EXAMPLE:

this.$toast('Simple!', {
  duration: 1000,
  pauseOnHover: false,
  styles: {
    borderRadius: '25px',
  },
  link: {
    href: 'https://vue-dk-toast.netlify.app/',
    targetBlank: true,
  },
  // Any valid HTML, intended for icons
  slotLeft: '<i class="fa fa-user"></i>', // Add icon to left
  slotRight: '<i class="fa fa-thumbs-up"></i>', // Add icon to right
  class: 'local-class', // Added to this toast only
  type: 'success', // Default classes: 'success', 'error' and 'passive'
  positionX: 'center',
  positionY: 'top',
  disableClick: true,
});

TypeScript Support

vue-dk-toast comes with it's own built-in types for most cases, the exception being with the Composition API:

<script lang="ts">
  import { defineComponent, inject } from 'vue';
  import type { Toast } from 'vue-dk-toast';

  export default defineComponent({
    setup() {
      const toast = inject<Toast>('$toast');

      if (toast) toast('Simple!');
    },
  });
</script>

Security

For slotRight and slotLeft to work, it uses innerHTML to set the content. innerHTML is not secure as it adds the possibility for XSS attacks. If you set any user-inputted tags with these options, make sure you sanitise the string beforehand, else, adding something like <img src=x onerror="alert("XSS Attack!")" /> would run. You can use a library like DOMPurify to handle this for you.


Contributions welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].