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

display-toast

v1.0.0

Published

A customizable toast message package for displaying notifications globally

Downloads

4

Readme

Custom Toast Messages

A lightweight, customizable toast notification package for displaying beautiful toast messages in web applications and as a global CLI tool.

Features

  • 🎨 Beautiful Design: Modern, clean toast notifications with smooth animations
  • 🎯 Multiple Types: Success, Error, Warning, and Info toast types
  • 📍 Flexible Positioning: Top-right, top-left, bottom-right, bottom-left, or center
  • ⏱️ Customizable Duration: Set custom display duration for each toast
  • 🔧 Highly Customizable: Progress bars, close buttons, custom classes, and more
  • 🌐 Global CLI Tool: Use as a command-line tool to display toast messages
  • 📦 Zero Dependencies: Lightweight with no external dependencies
  • 🎭 Smooth Animations: Entrance and exit animations with CSS transitions

Installation

As a Library

npm install custom-toast-messages

As a Global CLI Tool

npm install -g custom-toast-messages

Usage

JavaScript Library

Basic Usage

import { toast } from 'custom-toast-messages';

// Simple toast
toast.show('Hello World!');

// Success toast
toast.success('Operation completed successfully!');

// Error toast
toast.error('Something went wrong!');

// Warning toast
toast.warning('Please check your input');

// Info toast
toast.info('New message received');

Advanced Usage

// Custom options
toast.show('Custom message', {
  type: 'success',
  duration: 10000,
  position: 'center',
  showCloseButton: true,
  showProgressBar: true,
  customClass: 'my-custom-toast',
  onClick: () => console.log('Toast clicked!'),
  onClose: () => console.log('Toast closed!')
});

// Clear all toasts
toast.clear();

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | type | string | 'info' | Toast type: 'success', 'error', 'warning', 'info' | | duration | number | 5000 | Duration in milliseconds (0 for persistent) | | position | string | 'top-right' | Position: 'top-right', 'top-left', 'bottom-right', 'bottom-left', 'center' | | showCloseButton | boolean | true | Show/hide close button | | showProgressBar | boolean | true | Show/hide progress bar | | customClass | string | '' | Additional CSS class for styling | | onClick | function | null | Click handler for the toast | | onClose | function | null | Callback when toast is closed |

Global CLI Tool

Basic Usage

# Simple toast
toast "Hello World!"

# Success toast
toast -t success "Operation completed successfully!"

# Error toast with custom duration
toast -t error -d 10000 "Something went wrong!"

# Warning toast in center position
toast -t warning -p center "Please check your input"

# Info toast without progress bar
toast --type info --no-progress "New message received"

Interactive Mode

# Start interactive mode
toast -i
# or
toast --interactive

CLI Options

| Option | Short | Description | |--------|-------|-------------| | --type | -t | Toast type: success, error, warning, info | | --duration | -d | Duration in milliseconds | | --position | -p | Position: top-right, top-left, bottom-right, bottom-left, center | | --no-close | | Hide close button | | --no-progress | | Hide progress bar | | --help | -h | Show help message | | --version | -v | Show version | | --interactive | -i | Start interactive mode |

Examples

React Component Example

import React from 'react';
import { toast } from 'custom-toast-messages';

function MyComponent() {
  const handleSuccess = () => {
    toast.success('Data saved successfully!');
  };

  const handleError = () => {
    toast.error('Failed to save data', {
      duration: 8000,
      onClick: () => console.log('Error toast clicked')
    });
  };

  return (
    <div>
      <button onClick={handleSuccess}>Show Success</button>
      <button onClick={handleError}>Show Error</button>
    </div>
  );
}

Vanilla JavaScript Example

<!DOCTYPE html>
<html>
<head>
    <title>Toast Example</title>
</head>
<body>
    <button onclick="showToast()">Show Toast</button>
    
    <script type="module">
        import { toast } from './node_modules/custom-toast-messages/dist/index.js';
        
        window.showToast = function() {
            toast.success('This is a success message!', {
                duration: 3000,
                position: 'center'
            });
        };
    </script>
</body>
</html>

Styling

The package includes built-in styles, but you can customize them using CSS:

/* Custom toast styling */
.toast {
  /* Your custom styles */
}

.toast-success {
  background: linear-gradient(135deg, #28a745, #20c997);
  color: white;
}

.toast-error {
  background: linear-gradient(135deg, #dc3545, #e74c3c);
  color: white;
}

Browser Support

  • Chrome 60+
  • Firefox 55+
  • Safari 12+
  • Edge 79+

Development

Building the Package

# Install dependencies
npm install

# Build for production
npm run build

# Development build with watch
npm run dev

# Run tests
npm test

Publishing to npm

# Login to npm
npm login

# Publish package
npm publish

# Publish with specific tag
npm publish --tag beta

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Changelog

v1.0.0

  • Initial release
  • Basic toast functionality
  • Multiple toast types
  • Global CLI tool
  • Interactive mode
  • Customizable options