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

@rorycombe/toaster

v0.0.4

Published

A toaster web component

Downloads

38

Readme

Toaster

A beautiful, animated toast notification web component inspired by Sonner. Features a card-stacking effect with depth, smooth animations, and intelligent hover interactions.

Features

  • 🎨 Beautiful animations - Smooth slide-in animations and card stacking effects
  • 📚 Card stacking - Toasts stack on top of each other with a depth effect
  • 🎯 Hover interactions - Hover to pause timers and expand the full stack
  • ⏱️ Auto-hide - Toasts automatically hide after 5 seconds
  • 🎭 Multiple types - Support for success, error, warning, and info toasts
  • 🎪 Depth effect - Cards at the back are narrower and centered for a 3D effect
  • 📱 Web Component - Works with any framework or vanilla JavaScript

Installation

npm install @rorycombe/toaster

Quick Start

HTML

<!DOCTYPE html>
<html>
<head>
  <script type="module" src="node_modules/@rorycombe/toaster/dist/index.mjs"></script>
</head>
<body>
  <rc-toaster></rc-toaster>
  
  <script>
    const toaster = document.querySelector('rc-toaster');
    toaster.toast('Hello, world!', 'success');
  </script>
</body>
</html>

JavaScript/TypeScript

import '@rorycombe/toaster';

const toaster = document.querySelector('rc-toaster');
toaster.toast('Operation completed successfully!', 'success');

React

import { useEffect } from 'react';
import '@rorycombe/toaster';

function App() {
  useEffect(() => {
    const toaster = document.querySelector('rc-toaster');
    if (!toaster) {
      const element = document.createElement('rc-toaster');
      document.body.appendChild(element);
    }
  }, []);

  const showToast = (message, type) => {
    const toaster = document.querySelector('rc-toaster');
    toaster.toast(message, type);
  };

  return (
    <div>
      <button onClick={() => showToast('Success!', 'success')}>
        Show Success
      </button>
    </div>
  );
}

API

Methods

toast(message: string, type?: 'success' | 'error' | 'warning' | 'info'): void

Displays a toast notification.

Parameters:

  • message (string, required) - The message to display
  • type (string, optional) - The toast type. Defaults to 'success'

Toast Types:

  • 'success' - Green background (default)
  • 'error' - Red background
  • 'warning' - Yellow background
  • 'info' - Blue background

Example:

const toaster = document.querySelector('rc-toaster');

// Success toast (default)
toaster.toast('Operation completed!');

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

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

// Info toast
toaster.toast('Here is some information', 'info');

Behavior

Card Stacking

  • New toasts appear at the front of the stack
  • Up to 3 toasts are visible when not hovered
  • Cards further back are narrower and slightly scaled down for depth
  • Cards are centered relative to the front card for a 3D effect

Auto-Hide

  • Toasts automatically hide after 5 seconds
  • Timers pause when hovering over the toast area
  • Timers resume when you stop hovering
  • Hidden toasts can still be viewed when hovering over the stack

Hover Interactions

  • Hovering over any toast or the container:
    • Pauses all hide timers
    • Expands the stack to show all toasts
    • Cards space out evenly for readability
  • Moving away from the toast area:
    • Resumes timers with remaining time
    • Collapses the stack back to stacked view

Animations

  • Slide-in: New toasts slide in from the right
  • Slide-down: Toasts slide down when hiding
  • Stack shuffle: Existing toasts smoothly move back when new ones appear
  • Expand/Collapse: Smooth transitions when hovering

Styling

The toaster is positioned fixed at the bottom-right of the viewport. You can customize the position using CSS:

rc-toaster {
  bottom: 20px;
  right: 20px;
}

Toast colors can be customized by targeting the shadow DOM:

rc-toaster::part(toast-success) {
  background-color: your-color;
}

Examples

Multiple Toasts

const toaster = document.querySelector('rc-toaster');

// Show multiple toasts in sequence
['First', 'Second', 'Third'].forEach((msg, i) => {
  setTimeout(() => {
    toaster.toast(msg, ['success', 'error', 'warning'][i]);
  }, i * 500);
});

Error Handling

try {
  await someAsyncOperation();
  toaster.toast('Operation successful!', 'success');
} catch (error) {
  toaster.toast(`Error: ${error.message}`, 'error');
}

Browser Support

  • Chrome/Edge (latest)
  • Firefox (latest)
  • Safari (latest)
  • Any browser that supports Web Components and Shadow DOM

License

MIT

Author

Rory Combe