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

react-toaster-library

v1.1.3

Published

React library for creating toasters

Readme

React Toaster Library

A lightweight and customizable React Toaster component for displaying notifications in your React applications.

Features

  • Easy to use hook-based API.
  • Supports multiple notification types: success, warning, error, etc.
  • Customizable animations, positions, durations, and callbacks.
  • Responsive and styled out of the box.

Installation

Install the package using npm or yarn:

npm install react-toaster-library

or

yarn add react-toaster-library

Usage

Example Code

Here’s an example of how to use the toaster in your application:

import React from "react";
import "./styles.css"; // Import custom styles if needed
import useToasterHook from "react-toaster-library";

export default function App() {
  const { Toaster, trigger } = useToasterHook();

  return (
    <div className="App">
      {Toaster}
      <button
        onClick={() => {
          trigger({
            type: "warning", // Notification type (e.g., success, error)
            text: "This is a warning message!", // Message text
            position: "topLeft", // Position of the notification
            animation: "slide", // Animation style
            duration: 2000, // Display duration in milliseconds
            onClose: () => console.log("Notification closed!"), // Callback on close
          });
        }}
      >
        Show Notification
      </button>
    </div>
  );
}

API Reference

useToasterHook

Returns:

  • Toaster: A React component that renders the notifications.
  • trigger: A function used to trigger a new notification.

trigger Parameters:

| Parameter | Type | Description | Default | |------------|------------|----------------------------------------------------------------------------------------|------------| | type | string | Type of the notification (success, warning, error, etc.). | info | | text | string | The message text to display in the notification. | - | | position | string | Position of the notification (topLeft, topRight, bottomLeft, bottomRight). | topRight | | animation| string | Animation style for showing/hiding the notification (fade, slide, etc.). | fade | | duration | number | How long (in ms) the notification stays visible. | 3000 | | onClose | function | Callback function triggered when the notification is closed. | null |


Customization

Styling

You can override the default styles by providing your own CSS file. The Toaster component comes with minimal styles to ensure ease of customization. For example, include your own styles.css file:

/* Example styles.css */
.toaster {
  font-family: Arial, sans-serif;
  z-index: 9999;
}

.toaster-notification {
  padding: 16px;
  border-radius: 4px;
  color: #fff;
  box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
}

.toaster-notification.warning {
  background-color: #f4b400; /* Yellow for warnings */
}

Make sure to import your custom CSS file in your app:

import "./styles.css";

Contributing

Contributions are welcome! If you have ideas for new features, improvements, or bug fixes, feel free to contribute.

Steps to Contribute:

  • Fork this repository.
  • Create a new branch for your feature or bugfix.
  • Commit your changes with a clear message.
  • Push your branch and create a pull request.

License

This project is licensed under the MIT License.

MIT License

Copyright (c) 2024 Mohsin Shaikh

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Author

Maintained by Mohsin Shaikh


Support

If you find this library helpful, please consider giving it a ⭐ on GitHub!

If you encounter any issues or have questions, feel free to open an issue on GitHub or reach out at [email protected]