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

@perfectui/toastr

v1.3.0

Published

A modern, customizable toast notification library for Angular 19+

Readme

@perfectui/toastr

A modern, customizable toast notification library for Angular 19+.

npm version license

Features

  • ✨ Modern, beautiful design with multiple themes
  • 🎨 6 built-in themes (default, dark, light, minimal, outline, gradient)
  • 📍 6 position options (top-right, top-left, top-center, bottom-right, bottom-left, bottom-center)
  • ⏱️ Configurable duration and auto-dismiss
  • 📊 Progress bar with pause on hover
  • 🎯 Custom theme support with full color control
  • ♿ Accessible (ARIA support)
  • 📱 Responsive design
  • 🚫 Duplicate prevention
  • 🔔 Event subscriptions (click, close, timeout)

Installation

npm install @perfectui/toastr

Quick Start

1. Provide the toastr service

In your app.config.ts:

import { ApplicationConfig } from '@angular/core';
import { provideToastr } from '@perfectui/toastr';

export const appConfig: ApplicationConfig = {
  providers: [
    provideToastr({
      position: 'top-right',
      duration: 5000,
      maxToasts: 5,
      showProgressBar: true,
      showCloseButton: true,
      theme: 'default',
    }),
  ],
};

2. Inject and use the service

import { Component, inject } from '@angular/core';
import { ToastrService } from '@perfectui/toastr';

@Component({
  selector: 'app-root',
  template: `
    <button (click)="showSuccess()">Success</button>
    <button (click)="showError()">Error</button>
    <button (click)="showWarning()">Warning</button>
    <button (click)="showInfo()">Info</button>
  `,
})
export class AppComponent {
  private toastr = inject(ToastrService);

  showSuccess() {
    this.toastr.success('Operation completed successfully!', 'Success');
  }

  showError() {
    this.toastr.error('Something went wrong!', 'Error');
  }

  showWarning() {
    this.toastr.warning('Please review your input.', 'Warning');
  }

  showInfo() {
    this.toastr.info('New updates available.', 'Info');
  }
}

API Reference

ToastrService Methods

| Method | Description | |--------|-------------| | success(message, title?, options?) | Show a success toast | | error(message, title?, options?) | Show an error toast | | warning(message, title?, options?) | Show a warning toast | | info(message, title?, options?) | Show an info toast | | show(type, message, title?, options?) | Show a toast with custom type | | remove(toastId) | Remove a specific toast | | clear() | Remove all toasts |

Observables

| Observable | Description | |------------|-------------| | toasts$ | Stream of current toast array | | events$ | Stream of toast events (click, close, timeout) |

Configuration

Global Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | duration | number | 5000 | Duration in ms before auto-dismiss (0 for persistent) | | showCloseButton | boolean | true | Show close button | | showProgressBar | boolean | true | Show progress bar | | closeOnClick | boolean | true | Close toast on click | | pauseOnHover | boolean | true | Pause timer on hover | | position | ToastPosition | 'top-right' | Toast container position | | maxToasts | number | 5 | Maximum toasts displayed | | newestOnTop | boolean | true | Stack new toasts on top | | preventDuplicates | boolean | false | Prevent duplicate messages | | theme | ToastTheme | 'default' | Global theme for all toasts | | customClass | string | '' | Custom CSS class | | customThemeColors | ToastThemeColors | undefined | Custom colors (when theme is 'custom') |

Toast Positions

type ToastPosition = 
  | 'top-right' 
  | 'top-left' 
  | 'top-center' 
  | 'bottom-right' 
  | 'bottom-left' 
  | 'bottom-center';

Theming

Built-in Themes

| Theme | Description | |-------|-------------| | default | Gradient backgrounds with white text | | gradient | Same as default, vibrant gradient colors | | dark | Dark background with colored text and icons | | light | Light pastel backgrounds with dark text | | minimal | Clean, subtle design | | outline | Outlined style with transparent background |

provideToastr({
  theme: 'dark', // Use built-in dark theme
});

CSS Custom Properties (Recommended)

Customize colors using CSS variables in your styles.css:

:root {
  /* Override colors */
  --pui-success-500: #22c55e;
  --pui-success-600: #16a34a;
  --pui-error-500: #f43f5e;
  --pui-error-600: #e11d48;
  --pui-warning-500: #eab308;
  --pui-info-500: #0ea5e9;
  
  /* Customize toast appearance */
  --pui-toast-radius: 12px;
  --pui-toast-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  --pui-toast-min-width: 320px;
  --pui-toast-max-width: 450px;
}

Available CSS Variables

| Variable | Default | Description | |----------|---------|-------------| | --pui-success-500 | #10b981 | Main success color | | --pui-success-600 | #059669 | Success gradient end | | --pui-error-500 | #ef4444 | Main error color | | --pui-error-600 | #dc2626 | Error gradient end | | --pui-warning-500 | #f59e0b | Main warning color | | --pui-warning-600 | #d97706 | Warning gradient end | | --pui-info-500 | #3b82f6 | Main info color | | --pui-info-600 | #2563eb | Info gradient end | | --pui-toast-radius | 8px | Border radius | | --pui-toast-shadow | ... | Box shadow | | --pui-toast-min-width | 300px | Minimum width | | --pui-toast-max-width | 400px | Maximum width |

Per-Toast Theme Override

Override the theme for individual toasts:

this.toastr.success('Message', 'Title', { theme: 'dark' });

Events

Subscribe to toast events for custom handling:

import { Component, inject, OnInit } from '@angular/core';
import { ToastrService } from '@perfectui/toastr';

@Component({ ... })
export class AppComponent implements OnInit {
  private toastr = inject(ToastrService);

  ngOnInit() {
    // Subscribe to all toast events
    this.toastr.events$.subscribe(event => {
      switch (event.type) {
        case 'click':
          console.log('Toast clicked:', event.toast);
          break;
        case 'close':
          console.log('Toast closed:', event.toast);
          break;
        case 'timeout':
          console.log('Toast timed out:', event.toast);
          break;
      }
    });

    // Subscribe to toast list changes
    this.toastr.toasts$.subscribe(toasts => {
      console.log('Active toasts:', toasts.length);
    });
  }
}

Advanced Usage

Persistent Toast

Create a toast that doesn't auto-dismiss:

this.toastr.info('This will stay until closed', 'Persistent', {
  duration: 0,
  showCloseButton: true,
});

Custom Position Per Toast

this.toastr.success('Bottom notification', 'Success', {
  position: 'bottom-center',
});

Prevent Duplicates

provideToastr({
  preventDuplicates: true,
});

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

Changelog

See CHANGELOG.md for a detailed list of changes.

License

MIT © perfectUI