
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
vue-dk-toast
Advanced tools
vue-dk-toast
Lightweight toast-notification plugin for Vue 3 š
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā āā
āā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā āā
āā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā āā
āā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā āā
āā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā āā
āā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā āā
āā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā āā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āā āā
āā āā
āā āā
āā āā
āāāā āāāā
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/vue-dk-toast@3.2.1"></script>
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');
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>
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 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,
});
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>
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!
FAQs
Lightweight toast notification plugin for Vue 3
The npm package vue-dk-toast receives a total of 576 weekly downloads. As such, vue-dk-toast popularity was classified as not popular.
We found that vue-dk-toast demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Ā It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.