npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@erag/vue-toastification

v1.1.3

Published

A lightweight, high-performance **Toast Notification** and **Confirmation Modal** library for **Vue 3**. Built with **TypeScript** and the Composition API.

Readme

@erag/vue-toastification

A lightweight, high-performance Toast Notification and Confirmation Modal library for Vue 3. Built with TypeScript and the Composition API.

Version Vue TypeScript License

erag-vue-toastification

🚀 Features

  • Vue 3 Composition API support (useToast, useModal).
  • Promise-based Modals: Await user confirmation directly in your code (no callbacks needed).
  • Smooth Animations: Apple-style smooth entry, exit, and gap-filling transitions.
  • Fully Typed with TypeScript.
  • Lightweight & Zero dependencies.
  • Scoped CSS: Uses erag- prefix to prevent CSS conflicts with Bootstrap, Tailwind, etc.
  • Customizable: Control position, duration, content, and button labels.
  • 4 Built-in Toast Types: Success, Error, Warning, and Info.

📦 Installation

Install the package via npm:

npm install @erag/vue-toastification

⚙️ Setup

Register the plugin in your main Vue application file (usually main.ts or main.js). Important: Do not forget to import the CSS file.

import { createApp } from 'vue';
import App from './App.vue';

// 1. Import the plugin and styles
import ToastPlugin from '@erag/vue-toastification';
import '@erag/vue-toastification/dist/style.css';

const app = createApp(App);

// 2. Use the plugin
app.use(ToastPlugin, {
    position: 'bottom-right' // Default position for toasts
});

app.mount('#app');

🍞 Usage: Toast Notifications

Use the useToast composable to trigger non-blocking notifications.

1. Basic Usage

<script setup lang="ts">
    import { useToast } from '@erag/vue-toastification';

    const { success, error, warning, info } = useToast();

    const showToasts = () => {
        // Success (Green)
        success('Data saved successfully!', 'Good Job');

        // Error (Red) - Custom duration (5 seconds)
        error('Server connection failed.', 'Error', 5000);

        // Warning (Orange)
        warning('Your session is expiring.', 'Warning');

        // Info (Blue)
        info('New update available.', 'Info');
    };
</script>

2. Advanced: Dynamic Types (Handling API Responses)

Sometimes you receive the status type (e.g., 'success' or 'error') directly from an API response. Instead of writing multiple if-else statements, you can use bracket notation to call the toast method dynamically.

import { useToast } from '@erag/vue-toastification';
import type { ToastType } from '@erag/vue-toastification';

const toast = useToast();

const handleApiRequest = async () => {
    try {
        // Assume API returns: { status: 'success', message: 'Profile updated!' }
        const response = await api.updateProfile();

        // 1. Cast the string to ToastType
        const type = response.status as ToastType;

        // 2. Dynamic Call: Automatically calls toast.success() or toast.error()
        toast[type](response.message, 'Notification');
    } catch (err) {
        toast.error('Something went wrong');
    }
};

3. Changing Position Dynamically

You can change the position globally or for a specific toast.

Available Positions: top-left, top-center, top-right, bottom-left, bottom-center, bottom-right.

const { setPosition, success, info } = useToast();

// Method 1: Change Global Position (Affects all future toasts)
const updatePosition = () => {
    setPosition('top-center');
};

// Method 2: Pass Position to a specific Toast (One-time override)
const showCustomToast = () => {
    // success(msg, title, duration, position)
    success('I am shown at Top Left!', 'Custom Position', 4000, 'top-left');

    // You can also pass undefined for duration to use default
    info('I am at Bottom Center', 'Info', undefined, 'bottom-center');
};

💬 Usage: Confirmation Modals (New!)

Use the useModal composable to trigger blocking confirmation dialogs. The confirm() method returns a Promise that resolves to true (Confirmed) or false (Cancelled).

1. Danger / Delete Action (Red Button)

Use type: 'danger' for destructive actions like deleting data.

<script setup lang="ts">
import { useModal, useToast } from '@erag/vue-toastification';

const modal = useModal();
const toast = useToast();

const handleDelete = async () => {
    // Execution pauses here until the user clicks a button
    const isConfirmed = await modal.confirm({
        title: 'Delete Account?',
        message: 'Are you sure? This action cannot be undone.',
        confirmText: 'Yes, Delete',
        cancelText: 'No, Keep it',
        type: 'danger' // Makes the confirm button Red
    });

    if (isConfirmed) {
        // User clicked "Yes, Delete"
        console.log('User deleted account');
        toast.success('Account deleted successfully');
    } else {
        // User clicked "No" or Cancel
        toast.info('Action cancelled');
    }
};
</script>

2. General Confirmation (Info/Warning)

const logout = async () => {
    const ok = await modal.confirm({
        title: 'Logout',
        message: 'You have unsaved changes. Do you really want to leave?',
        confirmText: 'Logout',
        type: 'warning'
    });

    if (ok) {
        // Perform logout logic
    }
};

🎨 API Reference

1. useToast()

| Method | Arguments | Description | | ------------- | ---------------------------------------------------------------------------- | ---------------------------------------- | | success | (msg: string, title?: string, duration?: number, position?: ToastPosition) | Triggers a green success toast. | | error | (msg: string, title?: string, duration?: number, position?: ToastPosition) | Triggers a red error toast. | | warning | (msg: string, title?: string, duration?: number, position?: ToastPosition) | Triggers an orange warning toast. | | info | (msg: string, title?: string, duration?: number, position?: ToastPosition) | Triggers a blue info toast. | | setPosition | (position: ToastPosition) | Updates the global container position. | | remove | (id: number) | Manually removes a specific toast by ID. |

2. useModal()

| Method | Arguments | Returns | Description | | --------- | ------------------------- | ------------------ | --------------------------------------- | | confirm | (options: ModalOptions) | Promise<boolean> | Opens modal. Returns true if confirmed. |

ModalOptions Interface

| Property | Type | Default | Description | | :------------ | :-------------------------------- | :----------- | :------------------------------------------ | | title | string | Required | The bold heading of the modal. | | message | string | Required | The descriptive text body. | | confirmText | string | 'Confirm' | Label for the action button. | | cancelText | string | 'Cancel' | Label for the cancel button. | | type | 'danger' \| 'warning' \| 'info' | 'info' | Controls button colors (Danger = Red, etc). |


🛡️ CSS & Styling

This library uses the erag- prefix for all CSS classes to ensure it never breaks your existing UI.

  • Toast Container: .erag-toast-container
  • Modal Backdrop: .erag-modal-backdrop
  • Buttons: .erag-btn-confirm, .erag-btn-cancel

📄 License

MIT License © Er Amit Gupta