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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ngx-toast-lib

v1.1.5

Published

Uma biblioteca simples e leve para exibir **toasts** no Angular.

Readme

Angular Toast Library

Uma biblioteca simples e leve para exibir toasts no Angular.

🚀 Instalação

Você pode instalar a biblioteca via npm:

npm install ngx-toast-lib

Certifique-se de que o Tailwind CSS está configurado no seu projeto, já que a biblioteca utiliza estilos do Tailwind.


🔧 Configuração

Utilize o cdn do Iconify na index.html do seu Projeto + Links(consulta):

https://icon-sets.iconify.design/ https://iconify.design/

<script src="https://code.iconify.design/iconify-icon/2.1.0/iconify-icon.min.js"></script>

Se você ainda não configurou o Tailwind CSS no seu projeto Angular, siga estas etapas:

  1. Instale as dependências do Tailwind:

    npm install -D tailwindcss postcss autoprefixer
    npx tailwindcss init
  2. Configure o arquivo tailwind.config.js:

    module.exports = {
      content: [
        "./src/**/*.{html,ts}",
        "./node_modules/angular-toast-lib/**/*.{html,ts}",
      ],
      theme: {
        extend: {},
      },
      plugins: [],
    };
  3. Adicione o Tailwind ao seu arquivo src/styles.css:

    @tailwind base;
    @tailwind components;
    @tailwind utilities;

🛠️ Como Usar

1. Importe o BrowserAnimationsModule

No arquivo main.ts ou no seu componente standalone:

import { bootstrapApplication, BrowserModule } from "@angular/platform-browser";
import { AppComponent } from "./app/app.component";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { importProvidersFrom } from "@angular/core";

bootstrapApplication(AppComponent, {
  providers: [importProvidersFrom([BrowserModule, BrowserAnimationsModule])],
}).catch((err) => console.error(err));

2. Use o ToastComponent no Template

Adicione o componente de toast no seu template (geralmente no app.component.html):

<app-toast></app-toast>

3. Injete e Use o ToastService

No componente onde você deseja exibir o toast:

import { Component } from "@angular/core";
import { RouterOutlet } from "@angular/router";
import { ToastComponent, ToastService } from "toast";

@Component({
  selector: "app-root",
  standalone: true,
  imports: [RouterOutlet, ToastComponent],
  templateUrl: "./app.component.html",
  styleUrl: "./app.component.css",
})
export class AppComponent {
  constructor(private toastService: ToastService) {}

  showToast(): void {
    this.toastService.add({
      title: "Sucesso",
      message: "Operação realizada com sucesso!",
      type: "success", // 'success' | 'error' | 'welcome' | 'custom'
      duration: 3000, // Duração em milissegundos
    });
  }
}

✨ Exemplos de Estilos

Os toasts vêm com estilos básicos e utilizam Tailwind CSS. Aqui estão os estilos suportados:

| Tipo | Classe Tailwind | Cor Padrão | | --------- | ---------------- | ---------- | | success | .bg-green-500 | Verde | | error | .bg-red-200 | Vermelho | | welcome | .bg-purple-300 | Roxo |

Você pode personalizar esses estilos diretamente no arquivo de estilos da sua aplicação.


📝 Documentação do ToastService

Método add

Adiciona um novo toast.

Parâmetros:

  • message (string): Mensagem do toast.
  • type (string): Tipo do toast (success, error, welcome, custom).
  • duration (number): Duração do toast em milissegundos (padrão: 3500).
  • se for custom, teremos (title, icon, iconColor, bgColor).

Exemplo:

this.toastService.add({
  title: "Toast Error",
  message: "Ocorreu um erro.",
  type: "error",
  duration: 5000,
});

Exemplo de Custom:

this.toastService.add({
  title: "Custom",
  icon: "dashicons:welcome-learn-more",
  iconColor: "text-white",
  bgColor: "bg-gray-300",
  message: "teste de toast",
  duration: 2000,
  type: "custom",
});

🌟 Contribuições

Sinta-se à vontade para contribuir com melhorias! Basta abrir uma issue ou enviar um pull request no repositório do GitHub.


📄 Licença

Esta biblioteca está licenciada sob a licença MIT. Consulte o arquivo LICENSE para mais informações.