react-light-toast

1.0.8 • Public • Published

React Light Toast

Simple and lightweight toast package for React.js

Example



Installation

$ npm install react-light-toast
$ yarn add react-light-toast



Usage

  import React from 'react';

  import ToastContainer, { toast } from 'react-light-toast';
  
  function App(){
    const notify = () => toast.info('This is a toast!');

    return (
      <div>
        <button onClick={notify}>Notify!</button>
        <ToastContainer />
      </div>
    );
  }




Options

ToastContainer options

    <>
        <ToastContainer options={{ 
          reverse: true,
          position: 'bottom-right'
        }} /> 
    </>

    // reverse: reverse order of last toast (last toast adding to top)
    // positions: top-right, top-left, bottom-right, bottom-left, top-center, bottom-center // default: bottom-right

Toast options

    toast.info('This is a toast!', {
        autoClose: false, // disable auto close | default: true
        closeDuration: 3000, // close duration in ms | default: 3000
    });

Toast types

    toast.add('info', 'This is a info toast!');

    toast.info('This is a info toast!');
    toast.success('This is a success toast!');
    toast.error('This is a error toast!');
    toast.warning('This is a warning toast!');




Package Sidebar

Install

npm i react-light-toast

Weekly Downloads

2

Version

1.0.8

License

ISC

Unpacked Size

15.9 kB

Total Files

4

Last publish

Collaborators

  • fuadpashayev