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-basic-toastify

v3.0.1

Published

A simple toast notification component for React.

Readme

react-basic-toastify

A lightweight and customizable toast notification library for React.

Installation

Install the package via npm or yarn:

npm install react-basic-toastify
# or
yarn add react-basic-toastify
# or
pnpm add react-basic-toastify

Usage

Step 1: Wrap your application with ToastProvider

The ToastProvider is required to enable toast notifications in your application. Wrap it around the root component of your app.

import {ToastProvider} from 'react-basic-toastify';

export default function App() {
  return (
    <ToastProvider>
      <YourComponent/>
    </ToastProvider>
  );
}

Step 2: Use the toast object to show notifications

The toast object provides methods for displaying notifications. You can use it in any child component of the ToastProvider.

import { toast } from 'react-basic-toastify';

export default function Example() {
  return (
    <div>
      <button onClick={() => toast.success('This is a success message!')}>
        Show Success Toast
      </button>
      <button onClick={() => toast.error('This is an error message!')}>
        Show Error Toast
      </button>
      <button onClick={() => toast.info('This is an info message!')}>
        Show Info Toast
      </button>
    </div>
  );
}

API

ToastProvider

The ToastProvider component is a wrapper for your app to enable toast notifications.

Props

| Prop Name | Type | Default | Description | |-----------|--------|--------------|--------------------------------------------------------------------------------------------------| | position | string | "top-right" | Defines where the toast notifications appear. Options: "top-left", "top-right", "bottom-left", "bottom-right". |

Example:

<ToastProvider position="bottom-right">
  <YourComponent />
</ToastProvider>

toast Object

The toast object provides methods for displaying toast notifications.

Methods

| Method | Parameters | Description | |-----------------------------------|--------------------------------------------------------------|--------------------------------------| | toast.success(message, duration, showCloseButton) | message: string, duration?: number, showCloseButton?: boolean | Displays a success notification. | | toast.error(message, duration, showCloseButton) | message: string, duration?: number, showCloseButton?: boolean | Displays an error notification. | | toast.info(message, duration, showCloseButton) | message: string, duration?: number, showCloseButton?: boolean | Displays an info notification. |

Parameters

| Parameter | Type | Default | Description | |-------------------|----------|----------|--------------------------------------------------------------------| | message | string | (none) | The text to display in the toast notification. | | duration | number | 3000 | The time in milliseconds before the toast disappears automatically.| | showCloseButton | boolean| true | Whether to show the close button in the toast notification. |

Example:

import { toast } from 'react-basic-toastify';

toast.success('Operation successful!', 5000, true);
toast.error('An error occurred!', 4000);
toast.info('Here is some information.', 3000, false);

Customizing Styles

You can customize the appearance of the toast notifications by overriding CSS variables.

Default CSS Variables

  --toast-background-color: #333;
  --toast-text-color: #fff;
  --toast-success-color: #4caf50;
  --toast-error-color: #f44336;
  --toast-info-color: #2196f3;

Example: Custom Styling

  --toast-background-color: #000;
  --toast-text-color: #e0e0e0;
  --toast-success-color: #28a745;
  --toast-error-color: #dc3545;
  --toast-info-color: #007bff;

Complete Example

Here’s how you can use the library in a complete setup:

import React from 'react';
import { ToastProvider, toast } from 'react-basic-toastify';

function App() {
  return (
    <ToastProvider position="top-right">
      <Example />
    </ToastProvider>
  );
}

function Example() {
  return (
    <div>
      <button onClick={() => toast.success('Success!', 5000, true)}>
        Show Success Toast
      </button>
      <button onClick={() => toast.error('Error!', 4000, true)}>
        Show Error Toast
      </button>
      <button onClick={() => toast.info('Info!', 3000, false)}>
        Show Info Toast
      </button>
    </div>
  );
}

export default App;

License

This library is licensed under the MIT License. See the LICENSE file for more details.