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

rojeru-toast

v1.0.0

Published

Librería moderna de mensajes toast para aplicaciones web, compatible con todos los frameworks y HTML puro

Readme

rojeru-toast

npm version License: MIT Bundle Size

Una librería moderna de mensajes toast para aplicaciones web, compatible con todos los frameworks y HTML puro.

Características

  • 🎨 Diseño moderno con 3 temas (light, dark, colored)
  • 📱 Totalmente responsive
  • 🎭 6 tipos de mensajes: info, success, warning, error, loading
  • Animaciones suaves (slide, fade, scale)
  • 🔧 Altamente personalizable
  • 🌐 Compatible con todos los frameworks: React, Vue, Angular, Svelte, etc.
  • 📦 Sin dependencias
  • 🏗️ API intuitiva y fluida

Instalación

NPM

npm install rojeru-toast

Yarn

yarn add rojeru-toast

CDN

<!-- CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/rojeru-toast@latest/dist/rojeru-toast.min.css">

<!-- JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/rojeru-toast@latest/dist/rojeru-toast.min.js"></script>

Uso Rápido

HTML Puro

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/rojeru-toast@latest/dist/rojeru-toast.min.css">
</head>
<body>
    <script src="https://cdn.jsdelivr.net/npm/rojeru-toast@latest/dist/rojeru-toast.min.js"></script>
    <script>
        // Usar globalmente
        rojeruToast.success('¡Operación exitosa!');
        
        // O crear instancia
        const toast = new RojeruToast();
        toast.info('Mensaje informativo');
    </script>
</body>
</html>

Módulos ES6

import RojeruToast from 'rojeru-toast';

// Crear instancia
const toast = new RojeruToast();

// Métodos principales
toast.info('Mensaje informativo');
toast.success('¡Éxito!');
toast.warning('Advertencia');
toast.error('Error encontrado');

// Toast con título
toast.withTitle('Título', 'Mensaje de contenido');

// Toast de carga
const loadingToast = toast.loading('Procesando...');
// Luego completarlo
setTimeout(() => {
    loadingToast.complete('¡Completado!');
}, 2000);

React

import React from 'react';
import RojeruToast from 'rojeru-toast';

function App() {
    const toast = React.useMemo(() => new RojeruToast(), []);

    const showToast = () => {
        toast.success('¡Mensaje desde React!');
    };

    return (
        <button onClick={showToast}>
            Mostrar Toast
        </button>
    );
}

Vue

<template>
    <button @click="showToast">Mostrar Toast</button>
</template>

<script>
import RojeruToast from 'rojeru-toast';

export default {
    data() {
        return {
            toast: null
        };
    },
    mounted() {
        this.toast = new RojeruToast();
    },
    methods: {
        showToast() {
            this.toast.success('¡Mensaje desde Vue!');
        }
    }
};
</script>

API

Métodos Principales

show(title, message, options)

Muestra un toast con título y mensaje.

// Sin título
toast.show('Mensaje simple');

// Con título
toast.show('Título', 'Mensaje del contenido');

// Con opciones
toast.show('Título', 'Mensaje', {
    type: 'success',
    duration: 5000,
    position: 'top-center',
    theme: 'dark'
});

Métodos de conveniencia

toast.info(message, options);
toast.success(message, options);
toast.warning(message, options);
toast.error(message, options);
toast.loading(message, options);
toast.withTitle(title, message, options);

Opciones

| Opción | Tipo | Default | Descripción | |--------|------|---------|-------------| | type | string | 'info' | Tipo de toast: 'info', 'success', 'warning', 'error', 'loading' | | duration | number | 3000 | Duración en milisegundos (0 = permanente) | | position | string | 'top-right' | Posición: 'top-right', 'top-left', 'top-center', 'bottom-right', 'bottom-left', 'bottom-center' | | theme | string | 'light' | Tema: 'light', 'dark', 'colored' | | dismissible | boolean | true | Si muestra botón de cerrar | | pauseOnHover | boolean | true | Pausa la desaparición al hacer hover | | animation | string | 'slide' | Animación: 'slide', 'fade', 'scale' | | closeOnClick | boolean | false | Cierra al hacer click en el toast |

Métodos de Instancia

Cada toast retornado tiene estos métodos:

const toastInstance = toast.info('Mensaje');

// Obtener ID
const id = toastInstance.getId();

// Actualizar contenido
toastInstance.update('Nuevo mensaje');
toastInstance.update('Nuevo título', 'Nuevo mensaje');

// Cambiar tipo
toastInstance.changeType('success', '¡Completado!');

// Completar toast de carga
toastInstance.complete('¡Proceso completado!');

// Ocultar manualmente
toastInstance.hide();

Métodos Globales

// Ocultar toast por ID
toast.hideById('toast-id');

// Ocultar el último toast
toast.hideLast();

// Ocultar todos los toasts de un tipo
toast.hideByType('success');

// Limpiar todos los toasts
toast.clear();

Personalización

Configuración Global

const toast = new RojeruToast();

// Cambiar opciones por defecto
toast.defaultOptions = {
    duration: 5000,
    position: 'top-center',
    theme: 'colored',
    animation: 'fade'
};

CSS Custom Properties

:root {
    --rojeru-toast-font-family: 'Arial, sans-serif';
    --rojeru-toast-border-radius: 8px;
    --rojeru-toast-spacing: 10px;
}

Ejemplos Avanzados

Toast Persistente

const persistentToast = toast.info('Actualizando datos...', {
    duration: 0,
    dismissible: false
});

// Actualizar cuando termine la operación
setTimeout(() => {
    persistentToast.changeType('success', '¡Datos actualizados!', {
        duration: 3000,
        dismissible: true
    });
}, 2000);

Toast con Acciones

const actionToast = toast.info('¿Deseas guardar los cambios?', {
    duration: 0,
    closeOnClick: false
});

// Agregar botones personalizados
setTimeout(() => {
    const btnContainer = document.createElement('div');
    btnContainer.style.marginTop = '10px';
    btnContainer.innerHTML = `
        <button onclick="guardar()">Guardar</button>
        <button onclick="cancelar()">Cancelar</button>
    `;
    
    actionToast.element.querySelector('.rojeru-toast-content')
        .appendChild(btnContainer);
}, 100);

Soporte para Frameworks

React Hook

// useToast.js
import { useRef } from 'react';
import RojeruToast from 'rojeru-toast';

export function useToast() {
    const toastRef = useRef(null);
    
    if (!toastRef.current) {
        toastRef.current = new RojeruToast();
    }
    
    return toastRef.current;
}

// Uso
function Component() {
    const toast = useToast();
    
    const handleClick = () => {
        toast.success('¡Hecho!');
    };
    
    return <button onClick={handleClick}>Click</button>;
}

Licencia

MIT © Rogelio Urieta Camacho (RojeruSan)

❤️ Donaciones

Donar