0.1.2 • Published 1 month ago

@ng-vibe/toastify v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

Available on npmjs

Elevate your Angular 17+ applications with fluid, customizable toast messages using @ng-vibe/toastify. This library enables you to create various toast messages that can be positioned anywhere on the screen, offering extensive configuration options to tailor each toast to your needs. Initialize through TypeScript without the need for HTML selectors for a fluid integration into your project.

Play with code at Stackblitz

@ng-vibe/toastify

Features

  • Multiple Positions: Place your toasts at any corner of the screen or even full-width at the top or bottom.
  • Custom Animations: Choose from a wide array of animations for both entrance and exit.
  • Flexible Configuration: Adjust text alignment, include a progress bar, and much more.
  • No HTML Selectors: Initialize and configure entirely through TypeScript for a clean, modular approach.
  • Support for Angular 17+: Designed to work smoothly with the latest versions of Angular.

Installation

  1. Install @ng-vibe/toastify using npm:

    npm install @ng-vibe/toastify
  2. Add @ng-vibe/toastify to your Angular module providers by importing provideNgVibeToastify:

    import { provideNgVibeToastify } from '@ng-vibe/toastify';
    ...
    providers: [
      ...,
      provideNgVibeToastify(),
    ],
  3. Incorporate the @ng-vibe/toastify styles into your application:

    // In angular.json
    "styles": [
      "./node_modules/@ng-vibe/toastify/styles/styles.css",
      ...
    ],

    Or in your main styles file:

    // In styles.scss
    @import '@ng-vibe/toastify/styles/styles';

Usage

To use @ng-vibe/toastify in your components, import ToastifyRemoteControl and initialize it:

import { ToastifyRemoteControl } from '@ng-vibe/toastify';

private toast: ToastifyRemoteControl = new ToastifyRemoteControl();

openToast() {
  this.toast.openToast('Message!', 'Title');
}

Configuring Options

Customize your toast by setting the options property before calling openToast():

this.toast.options = {
  text: 'Your message here!',
  title: 'Your title here',
  autoCloseDuration: 3000,
  layoutType: ToastTypeEnum.SUCCESS,
  position: ToastPosition.TOP_LEFT,
  progressBar: ProgressBar.DECREASE,
  textAlign: TextAlignEnum.START,
  animationIn: AppearanceAnimation.BOUNCE_IN,
  // additional options...
};
this.toast.openToast();

Options

OptionDescriptionType
animationInAnimation type for the toast appearance.AppearanceAnimation
animationOutAnimation type for the toast disappearance.DisappearanceAnimation
positionScreen position of the toast.ToastPosition
autoCloseDurationDuration before the toast automatically closes.number
progressBarType of progress bar displayed.ProgressBar
layoutTypeType of toast based on context (success, info, etc.)ToastTypeEnum
textAlignAlignment of the text within the toast.TextAlignEnum
showCloseWhether a close button is displayed.boolean
showIconWhether an icon is displayed.boolean
textText content of the toast.string
titleTitle of the toast.string

Contributing

We welcome contributions to make @ng-vibe/toastify even better! Whether you're fixing bugs, adding new features, or improving the documentation, your help is greatly appreciated. 🌟 Check out our contribution guidelines for more information.

License

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