Toast notifications for Angular 16+ powered by reactive signals and a drop-in view component.
- Lightweight service built on Angular signals for instant toast updates.
- Standalone
<toast-view>component with six placement presets. - Built-in icons and optional progress indicator, title, and custom fonts.
- Optional close button to let users dismiss notifications immediately.
- Global configuration helper to set defaults once at bootstrap.
- Theme-friendly CSS variables for background, border, and accent colors.
-
Install the library from npm:
npm install ngx-popify
-
Add the icon packages required by
ToastView:npm install @ng-icons/core @ng-icons/material-icons
-
Ensure your project targets Angular 16 or higher; the library relies on native signals.
-
Mount the global view component in your root template (for example in
AppComponent):// app.component.ts import { Component } from '@angular/core'; import { ToastView } from '@fgilmet/ngx-popify'; @Component({ selector: 'app-root', standalone: true, imports: [ToastView], template: ` <router-outlet /> <toast-view /> `, }) export class AppComponent {}
-
Inject the service wherever you need to trigger notifications:
import { Component } from '@angular/core'; import { ToastService } from '@fgilmet/ngx-popify'; @Component({ selector: 'app-dashboard', standalone: true, template: `<button (click)="notify()">Notify</button>`, }) export class DashboardComponent { constructor(private readonly toast: ToastService) {} notify() { this.toast.success('Operation completed successfully'); } }
toast.success('Saved successfully', {
header: 'Success',
duration: 5000,
position: 'bottom-left', // 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center'
showProgress: true,
showIcons: true,
closable: true,
fontFamily: 'Inter, sans-serif',
});By default the close button stays hidden; set closable: true globally or per toast to enable it.
Set global defaults once during bootstrap with provideToastConfig:
import { bootstrapApplication } from '@angular/platform-browser';
import { provideToastConfig } from '@fgilmet/ngx-popify';
import { AppComponent } from './app/app.component';
bootstrapApplication(AppComponent, {
providers: [
provideToastConfig({
header: 'Heads up',
duration: 4000,
position: 'bottom-center',
showProgress: true,
showIcons: false,
closable: true,
}),
],
});- Override the exposed CSS variables (
--toast-bg,--toast-border,--toast-base,--toast-text,--toast-text-secondary) to match your theme. - Use the
fontFamilyoption to set typography per toast. - Extend
.toast-viewor.toastwith your own margins, shadows, or transitions as needed.
ng build popifybuilds the library intodist/popify.ng testruns the unit tests.npm publish(executed fromdist/popify) publishes the package to npm when ready.
Distributed under the MIT license.
