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

@su-labs/notifications

v21.0.5

Published

`@su-labs/notifications`

Readme

Notifications

@su-labs/notifications

Angular Angular Version TypeScript License NPM Size Downloads Version

A highly customizable Angular notification library built with modern practices, including reactive Signals. Easily display different types of notifications with various positions, custom icons, and optional auto-closing behavior.

📚 Table of Contents

💡 Why Use This Library?

  • 🎯 Lightweight - Minimal bundle size
  • Reactive - Built with Angular Signals
  • 🎨 Customizable - Multiple themes and positions
  • 🖼️ Icon Support - Default SVG or custom icons
  • ⏱️ Auto-dismiss - Configurable duration
  • 🔒 Type-Safe - Full TypeScript support
  • 📦 Zero Dependencies - No bloat
  • 🧪 Well Tested - Comprehensive test coverage
  • 📝 Well Documented - Clear examples and API docs

Features

  • Reactive Core: Built on Angular Signals for optimal performance and reactive updates.
  • Multiple Positions: Notifications can be displayed in six different positions (top-right, top-left, bottom-right, bottom-left, top-center, bottom-center).
  • Customizable: Easily change themes, icons, and CSS classes to match your application's design system.
  • Icon Support:
    • Default Icons: Render a default SVG icon based on the notification type.
    • Custom Icons: Use a custom SVG string or an image URL as an icon.
  • Dismissible: Notifications can be dismissed manually or set to auto-close after a specified duration.
  • Declarative Usage: Add a single component to your root template and use the service from anywhere in your application.

Installation

You can install this library via npm:

npm install @su-labs/notifications

Peer Dependencies

This library requires the following peer dependencies:

npm install @angular/common@^21 @angular/core@^21

🚀 Quick Start

// 1. Install
npm install @su-labs/notifications

// 2. Add component to your app template
// app.component.html
<su-notifications></su-notifications>
<router-outlet></router-outlet>

// 3. Show notifications from any component
import { Component, inject } from '@angular/core';
import { SuNotificationService } from '@su-labs/notifications';

@Component({
  template: `<button (click)="showSuccess()">Show Success</button>`
})
export class AppComponent {
  notificationService = inject(SuNotificationService);

  showSuccess() {
    this.notificationService.show({
      type: 'success',
      message: 'Operation completed!'
    });
  }
}

Usage

1. Add the component to your application

Add the <su-notifications></su-notifications> component to your root AppComponent or index.html file. This component acts as a container for all notifications.

<!-- src/app/app.component.html -->
<su-notifications></su-notifications>
<router-outlet></router-outlet>

2. Inject the service and show a notification

Inject the SuNotificationService into any component or service and call its show() method to display a new notification.

// src/app/my-example.component.ts
import { Component, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SuNotificationService } from '@su-labs/notifications';

@Component({
  selector: 'app-my-example',
  standalone: true,
  imports: [CommonModule],
  template: `
    <div class="example-container">
      <button (click)="showSuccess()">Show Success</button>
      <button (click)="showError()">Show Error</button>
      <button (click)="showCustom()">Show Custom Icon</button>
    </div>
  `
})
export class MyExampleComponent {
  private readonly notificationService = inject(SuNotificationService);

  showSuccess(): void {
    this.notificationService.show({
      type: 'success',
      message: 'Your action was successful!'
    });
  }

  showError(): void {
    this.notificationService.show({
      type: 'error',
      message: 'Something went wrong. Please try again.'
    });
  }

  showCustom(): void {
    this.notificationService.show({
      type: 'info',
      message: 'This is a custom icon notification.',
      icon: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon></svg>`
    });
  }
}

3. Customize the position

You can configure the global position of all notifications by directly setting the position property on the service instance. This is best done during application initialization.

// src/app/app.config.ts
import { ApplicationConfig, inject, provideAppInitializer } from '@angular/core';
import { SuNotificationService } from '@su-labs/notifications';

export const appConfig: ApplicationConfig = {
  providers: [
    provideAppInitializer(() => {
      const notificationService = inject(SuNotificationService);
      notificationService.position = 'bottom-left';
    }),
    // other providers
  ],
};

📖 API Reference

Service (SuNotificationService)

Properties

| Property | Type | Description | |----------|------|-------------| | position | NotificationPosition | Global notification position |

Methods

| Method | Parameters | Description | |--------|------------|-------------| | show(config) | NotificationConfig | Display a new notification | | dismiss(id) | string | Manually dismiss a notification |

Types

type NotificationType = 'info' | 'success' | 'warning' | 'error' | 'custom';

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

interface NotificationConfig {
  type: NotificationType;
  message: string;
  duration?: number;        // Default: 3000ms
  autoClose?: boolean;      // Default: true
  cssClass?: string;        // Custom CSS class
  icon?: string;            // Custom SVG string or image URL
}

Configuration Options

Notification Types

| Type | Description | Default Icon | |------|-------------|--------------| | info | Informational message | ℹ️ | | success | Success message | ✅ | | warning | Warning message | ⚠️ | | error | Error message | ❌ | | custom | Custom styled message | 🔔 |

Positions

| Position | Description | |----------|-------------| | top-right | Top right corner (default) | | top-left | Top left corner | | top-center | Top center | | bottom-right | Bottom right corner | | bottom-left | Bottom left corner | | bottom-center | Bottom center |

How It Works

The library consists of a stateless service (SuNotificationService) and a presentational component (SuNotificationComponent).

The service manages a list of notifications using a private Signal. When you call service.show(), it adds a new notification object to the signal's array. The component then reads from this signal and automatically renders a notification for each item in the array. This approach keeps the state management decoupled from the UI, making it highly flexible and testable.

The component's icons are rendered using [innerHTML] to safely inject SVG markup into the template. Angular's DomSanitizer is used to prevent security risks like Cross-Site Scripting (XSS) attacks.

🌐 Browser Compatibility

Works in all modern browsers that support:

  • ✅ CSS Flexbox
  • ✅ CSS Animations
  • ✅ Angular 21+
  • ✅ ES2022+

| Browser | Version | |---------|---------| | Chrome | ≥ 90 | | Firefox | ≥ 88 | | Safari | ≥ 14 | | Edge | ≥ 90 |

🔗 Related Libraries

Part of the @su-labs suite:

🔧 Troubleshooting

Notifications not showing?

Make sure you've added <su-notifications></su-notifications> to your root component template.

Icons not displaying?

If using custom icons, ensure the SVG string is valid. For security, Angular sanitizes HTML by default.

Position not changing?

Set the position property during app initialization using provideAppInitializer.

TypeScript errors?

Ensure you have Angular 21+ and TypeScript 5.7+ installed.

💬 Support

Contributing

If you find any bugs or have feature requests, please open an issue or submit a pull request on our GitHub repository.

To contribute code, please ensure your changes include unit tests to maintain code quality. Please see the main repository's README.md for details on the monorepo structure.

License

This project is licensed under the MIT License. See the LICENSE file for details.