react-light-toast
v1.0.8
Published
Simple and lightweight toast package for React.js
Downloads
7
Maintainers
Readme
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!');