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

react-toast-drei

v1.0.10

Published

a simple react toast made by Andrei R. Parquez

Readme

React Toast Drei

A simple and elegant React toast notification component created by Andrei R. Parquez.

Features

  • 🎨 Beautiful, modern toast notifications with smooth animations
  • 🎯 Four different toast types: Success, Error, Info, and Warning
  • ⏱️ Customizable duration with visual progress bar
  • 🎬 Smooth enter/exit animations powered by Framer Motion
  • 🎨 Tailwind CSS styling with custom colors for each toast type
  • 📱 Responsive design that works on all screen sizes
  • 🔧 Easy to integrate and customize

Installation

npm install react-toast-drei

Dependencies

Make sure you have the following peer dependencies installed:

npm install framer-motion lucide-react react-icons tailwindcss

Tailwind CSS Setup

This package requires Tailwind CSS to be configured in your project. If you haven't set up Tailwind CSS yet:

  1. Install Tailwind CSS Install tailwindcss and @tailwindcss/vite via npm.

    npm install tailwindcss @tailwindcss/vite
  2. Configure the Vite plugin Add the @tailwindcss/vite plugin to your Vite configuration.

    import { defineConfig } from 'vite'
    import tailwindcss from '@tailwindcss/vite'
    export default defineConfig({
      plugins: [
        tailwindcss(),
      ],
    })
  3. Import Tailwind CSS Add an @import to your CSS file that imports Tailwind CSS.

    @import "tailwindcss";
  4. Start your build process Run your build process with npm run dev or whatever command is configured in your package.json file.

    npm run dev
  5. Start using Tailwind in your HTML Make sure your compiled CSS is included in the <head> (your framework might handle this for you), then start using Tailwind's utility classes to style your content.

Usage

Basic Setup

  1. First, wrap your app with the ToastProvider:
import ToastProvider from 'react-toast-drei';
import App from './App';

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

export default Root;
  1. Use the useToast hook in your components:
import { useToast } from 'react-toast-drei';

export default function MyComponent() {
  const toast = useToast();

  const handleSuccess = () => {
    toast('success', 'Operation completed successfully!');
  };

  const handleError = () => {
    toast('error', 'Something went wrong!');
  };

  const handleInfo = () => {
    toast('info', 'Here is some information for you.');
  };

  const handleWarning = () => {
    toast('warning', 'Please be careful with this action.');
  };

  return (
    <div>
      <button onClick={handleSuccess}>Show Success Toast</button>
      <button onClick={handleError}>Show Error Toast</button>
      <button onClick={handleInfo}>Show Info Toast</button>
      <button onClick={handleWarning}>Show Warning Toast</button>
    </div>
  );
}

Custom Duration

You can customize the duration of each toast (default is 5000ms):

const toast = useToast();

// Toast will disappear after 3 seconds
toast('success', 'Quick message!', 3000);

// Toast will disappear after 10 seconds
toast('error', 'Important error message!', 10000);

Toast Types

Success Toast

  • Color: Green
  • Icon: Check mark
  • Use case: Successful operations, confirmations

Error Toast

  • Color: Red
  • Icon: Triangle alert
  • Use case: Error messages, failed operations

Info Toast

  • Color: Blue
  • Icon: Information circle
  • Use case: General information, tips

Warning Toast

  • Color: Yellow/Orange
  • Icon: X mark
  • Use case: Warnings, cautions

Customization

The toast component uses Tailwind CSS classes and can be customized by modifying the styles in the source files. Each toast type has its own:

  • Background color for the icon container
  • Progress bar color
  • Themed icon

API Reference

useToast()

Returns a function to create toast notifications.

Parameters:

  • status (string): The type of toast - 'success', 'error', 'info', or 'warning'
  • message (string): The message to display in the toast
  • duration (number, optional): Duration in milliseconds (default: 5000)

ToastProvider

Context provider that manages toast state and rendering.

Props:

  • children: React components to wrap

Requirements

  • React 18.0.0 or higher
  • Framer Motion 11.0.0 or higher
  • Lucide React 0.292.0 or higher
  • React Icons 4.10.1 or higher
  • Tailwind CSS (for styling)

License

ISC

Author

Andrei R. Parquez


Made with ❤️ for the React community