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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@input-kit/toast

v1.0.1

Published

Headless toast notification library for React

Readme

@input-kit/toast

Headless toast notification library for React with full TypeScript support.

Features

  • 🎯 Multiple toast types: success, error, warning, info
  • 📍 6 positions: top-left, top-center, top-right, bottom-left, bottom-center, bottom-right
  • ⏱️ Auto-dismiss with progress bar
  • ⏸️ Pause on hover
  • 👆 Swipe to dismiss (mobile)
  • 🔄 Promise toasts: loading → success/error
  • 🔘 Action buttons in toasts
  • ⌨️ Keyboard support (Escape to dismiss)
  • 📚 Toast stacking/limit
  • 🎨 Headless design: bring your own styles
  • 🔷 Full TypeScript support

Installation

npm install @input-kit/toast
# or
yarn add @input-kit/toast
# or
pnpm add @input-kit/toast

Quick Start

1. Wrap your app with ToastProvider

import { ToastProvider } from '@input-kit/toast';

function App() {
  return (
    <ToastProvider>
      <YourApp />
    </ToastProvider>
  );
}

2. Use the useToast hook

import { useToast } from '@input-kit/toast';

function MyComponent() {
  const { success, error, info, warning, promise } = useToast();

  const handleClick = () => {
    success('Operation completed!');
  };

  const handleSave = async () => {
    await promise(saveData(), {
      loading: 'Saving...',
      success: 'Saved successfully!',
      error: 'Failed to save',
    });
  };

  return (
    <>
      <button onClick={handleClick}>Show Success</button>
      <button onClick={handleSave}>Save Data</button>
    </>
  );
}

API Reference

ToastProvider

<ToastProvider
  maxToasts={10}           // Maximum number of toasts shown at once
  defaultDuration={3000}   // Default duration in ms
  defaultPosition="bottom-right"  // Default position
  reverseOrder={false}     // Reverse toast order
  gutter={8}              // Gap between toasts in px
  containerStyle={{}}      // Custom container styles
  toastStyle={{}}          // Custom toast styles
>
  {children}
</ToastProvider>

useToast Hook

const toast = useToast();

// Basic toasts
toast.success(message, options?);
toast.error(message, options?);
toast.warning(message, options?);
toast.info(message, options?);
toast.custom(message, options?);

// Promise toast
await toast.promise(promise, {
  loading: 'Loading...',
  success: 'Success!',
  error: 'Error!',
});

// Dismiss
toast.dismiss(toastId);
toast.dismissAll();

Toast Options

interface ToastOptions {
  id?: string;              // Custom ID
  type?: 'success' | 'error' | 'warning' | 'info';
  title?: string;           // Toast title
  duration?: number;        // Duration in ms (0 = infinite)
  position?: ToastPosition; // Toast position
  action?: {                // Action button
    label: string;
    onClick: () => void;
    variant?: 'primary' | 'secondary' | 'danger';
  };
  onDismiss?: () => void;   // Callback on dismiss
  onAutoClose?: () => void; // Callback on auto-close
}

Positions

  • top-left
  • top-center
  • top-right
  • bottom-left
  • bottom-center
  • bottom-right

Standalone Usage (Outside React)

import { toast } from '@input-kit/toast';

// Can be used outside React components
toast.success('Hello!');
toast.error('Something went wrong');
toast.promise(fetchData(), {
  loading: 'Loading...',
  success: 'Done!',
  error: 'Failed!',
});

Styling

The library is headless - you provide your own styles. Each toast has CSS classes you can target:

.toast {
  /* Base toast styles */
}

.toast--success { /* Success variant */ }
.toast--error { /* Error variant */ }
.toast--warning { /* Warning variant */ }
.toast--info { /* Info variant */ }

.toast--entering { /* Enter animation */ }
.toast--exiting { /* Exit animation */ }

.toast__icon { /* Icon element */ }
.toast__content { /* Content wrapper */ }
.toast__title { /* Title element */ }
.toast__message { /* Message element */ }
.toast__action { /* Action button */ }
.toast__close { /* Close button */ }
.toast__progress { /* Progress bar container */ }
.toast__progress-bar { /* Progress bar fill */ }

Example Custom Styles

<ToastProvider
  toastStyle={{
    backgroundColor: '#1f2937',
    color: '#f3f4f6',
    borderRadius: '12px',
    boxShadow: '0 10px 40px rgba(0,0,0,0.3)',
  }}
/>

Examples

With Action Button

toast.success('Item deleted', {
  action: {
    label: 'Undo',
    onClick: () => {
      // Undo the deletion
      restoreItem();
    },
  },
});

Custom Duration

toast.info('This will stay for 10 seconds', {
  duration: 10000,
});

// Infinite duration (manual dismiss only)
toast.error('Critical error!', {
  duration: 0,
});

Different Positions

toast.success('Top right toast', { position: 'top-right' });
toast.error('Bottom center toast', { position: 'bottom-center' });

Promise with Dynamic Messages

await toast.promise(
  fetchUser(userId),
  {
    loading: 'Loading user...',
    success: (user) => `Welcome, ${user.name}!`,
    error: (err) => `Failed: ${err.message}`,
  }
);

TypeScript

Full TypeScript support with exported types:

import type { ToastOptions, ToastPosition, ToastType } from '@input-kit/toast';

Browser Support

  • Chrome/Edge 80+
  • Firefox 75+
  • Safari 13.1+

License

MIT