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

@todovue/tv-alert

v1.2.0

Published

A simple and customizable alert component for Vue.js applications.

Downloads

134

Readme

TODOvue Alert (TvAlert)

A flexible, framework‑agnostic Vue 3 alert/notification component with multiple positions, types, progress bar, pause on hover, and customization utilities. Ship it in Single Page Apps or Server-Side Rendered (SSR) environments (e.g. Nuxt 3) with zero DOM assumptions.

npm npm downloads npm total downloads License Release Date Bundle Size Node Version Last Commit Stars

Demo: https://ui.todovue.blog/alert

Table of Contents

Features

  • Multiple alert types: info, success, warning, error
  • Six position options: top-right, top-center, top-left, bottom-right, bottom-center, bottom-left
  • Auto-dismiss with customizable duration
  • Progress bar showing remaining time
  • Pause on hover (configurable)
  • Optional close button
  • Stack multiple alerts in the same position (with max limit)
  • Programmatic API via composable (useAlert)
  • Smooth slide-in/slide-out transitions
  • Works in SPA and SSR (Nuxt 3) contexts
  • Tree-shake friendly (Vue marked external in library build)

Installation

Using npm:

npm install @todovue/tv-alert

Using yarn:

yarn add @todovue/tv-alert

Using pnpm:

pnpm add @todovue/tv-alert

Quick Start (SPA)

Global registration (main.js / main.ts):

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

import '@todovue/tv-alert/style.css'
import { TvAlert } from '@todovue/tv-alert'

const app = createApp(App)
app.component('TvAlert', TvAlert)
app.mount('#app')

In your root component (App.vue):

<template>
  <div id="app">
    <TvAlert />
    <router-view />
  </div>
</template>

Using the alert in any component:

<script setup>
import { useAlert } from '@todovue/tv-alert'

const { api } = useAlert()
const alert = api()

function showNotification() {
  alert.success('Operation completed successfully!')
}
</script>

<template>
  <button @click="showNotification">Show Alert</button>
</template>

Nuxt 3 / SSR Usage

Step 1: Add the stylesheet to your nuxt.config.ts:

// nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    '@todovue/tv-alert/nuxt'
  ]
})

Step 2: Create a plugin file: plugins/tv-alert.client.ts (client-only is fine, or without suffix for SSR as it is safe):

import { defineNuxtPlugin } from '#app'
import { TvAlert } from '@todovue/tv-alert'

export default defineNuxtPlugin(nuxtApp => {
  nuxtApp.vueApp.component('TvAlert', TvAlert)
})

Step 3: Add the component to your app.vue or layout:

<template>
  <div>
    <TvAlert />
    <NuxtPage />
  </div>
</template>

Use anywhere:

<script setup>
import { useAlert } from '@todovue/tv-alert'

const { api } = useAlert()
const alert = api()

function notify() {
  alert.info('Welcome to our app!')
}
</script>

Component Registration Options

| Approach | When to use | |-------------------------------------------------------------------|------------------------------------------------| | Global via app.use(TvAlert) | Recommended - single instance across app | | Local named import { TvAlert } | When you need multiple alert containers | | Direct default import import TvAlert from '@todovue/tv-alert' | Single usage or manual registration |

Props

The TvAlert component accepts the following props:

| Prop | Type | Default | Description | |------|--------|---------|--------------------------------------------------| | max | Number | 8 | Maximum number of alerts to display per position |

Example:

<TvAlert :max="5" />

Alert Options

When calling alert.open() or type-specific methods, you can pass an options object:

| Option | Type | Default | Description | |---------------|---------|--------------|-------------------------------------------------------| | title | String | null | Optional bold title above the message | | message | String | '' | The message to display in the alert | | type | String | 'info' | Alert type: 'info', 'success', 'warning', or 'error' | | position | String | 'top-right' | Position of the alert (see Positions section) | | duration | Number | 4000 | Duration in milliseconds (0 = never auto-dismiss) | | showClose | Boolean | true | Show/hide close button | | pauseOnHover | Boolean | true | Pause auto-dismiss timer on mouse hover | | showProgress | Boolean | true | Show/hide progress bar | | icon | String | null | Custom icon implementation (not widely used) | | customIcon | String | null | SVG/HTML string for a custom icon replacing default | | actions | Array | [] | Array of action buttons: { label, handler(item) } | | allowHtml | Boolean | false | Allow HTML content in the message |

Example:

alert.open({
  message: 'Custom alert',
  type: 'warning',
  position: 'bottom-center',
  duration: 6000,
  showClose: true,
  pauseOnHover: true,
  showProgress: true
})

Composable API (useAlert)

The useAlert composable provides methods to manage alerts programmatically:

import { useAlert } from '@todovue/tv-alert'

const { api, addAlert, removeAlert, clearAll, alerts } = useAlert()

// Get the simplified API
const alert = api()

// Type-specific methods
alert.info('Information message')
alert.success('Success message')
alert.warning('Warning message')
alert.error('Error message')

// Generic method with full options
alert.open({
  message: 'Custom alert',
  type: 'info',
  position: 'top-center',
  duration: 5000
})

// Direct methods
addAlert({ message: 'Direct call', type: 'success' })
clearAll() // Remove all alerts

// Access reactive alerts array
console.log(alerts.value) // Array of current alerts

API Methods

| Method | Parameters | Returns | Description | |-----------------|------------------|---------|--------------------------------------| | api() | none | Object | Returns simplified alert API | | alert.info() | message, options | Number | Show info alert, returns alert ID | | alert.success() | message, options | Number | Show success alert, returns alert ID | | alert.warning() | message, options | Number | Show warning alert, returns alert ID | | alert.error() | message, options | Number | Show error alert, returns alert ID | | alert.open() | options | Number | Show alert with custom options | | addAlert() | options | Number | Add alert directly | | removeAlert() | id | void | Remove specific alert by ID | | clearAll() | none | void | Remove all alerts |

Positions

TvAlert supports six different positions:

  • top-right (default)
  • top-center
  • top-left
  • bottom-right
  • bottom-center
  • bottom-left

Example:

alert.success('Top left notification', { position: 'top-left' })
alert.warning('Bottom center notification', { position: 'bottom-center' })

Alert Types

Four alert types are available, each with its own color scheme:

  • info - Blue themed (informational messages)
  • success - Green themed (success/completion messages)
  • warning - Orange/Yellow themed (warning messages)
  • error - Red themed (error/critical messages)

Examples:

alert.info('This is an information alert')
alert.success('Operation completed successfully!')
alert.warning('Please review your input')
alert.error('An error occurred')

Customization (Styles / Theming)

The component uses SCSS variables for theming. You can customize the appearance by overriding the CSS variables or by modifying the SCSS variables:

Colors are automatically applied based on the alert type. The component includes:

  • Type-specific background colors
  • Progress bar animations
  • Smooth slide transitions
  • Hover effects

For advanced customization, you can override the CSS classes:

.tv-alert {
  /* Custom styles */
}

.tv-alert--success {
  /* Custom success styles */
}

.tv-alert__progress-bar {
  /* Custom progress bar */
}

Accessibility

  • Each alert container has aria-live="polite" for screen reader announcements
  • Individual alerts have role="status" for proper ARIA semantics
  • Close buttons include aria-label for accessibility
  • Keyboard navigation supported (close button is focusable)

SSR Notes

  • No direct DOM (window / document) access in source → safe for SSR
  • Styles are automatically applied when you import the library
  • Works seamlessly with Nuxt 3 and other SSR frameworks
  • The composable uses Vue's reactivity system, compatible with SSR

Development

git clone https://github.com/TODOvue/tv-alert.git
cd tv-alert
npm install
npm run dev     # run demo playground
npm run build   # build library

Local demo served from Vite using index.html + src/demo examples.

Contributing

PRs and issues welcome. See CONTRIBUTING.md and CODE_OF_CONDUCT.md.

License

MIT © TODOvue

Attributions

Crafted for the TODOvue component ecosystem