Socket
Socket
Sign inDemoInstall

react-toast

Package Overview
Dependencies
3
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-toast

Minimal toast notifications for React.


Version published
Weekly downloads
1.7K
decreased by-6%
Maintainers
1
Install size
109 kB
Created
Weekly downloads
 

Readme

Source

React Toast

React Toast

Minimal toast notifications for React.

Get started

Quick start

Install with yarn

yarn add react-toast

Install with NPM

npm install react-toast
import { ToastContainer, toast } from 'react-toast'

const App = () => {
  const wave = () => toast('Hi there 👋')

  return (
    <div>
      <button onClick={wave}>Say hi!</button>
      <ToastContainer />
    </div>
  )
}

Demo

Demo on CodeSandbox.

Docs

Toast Container

To use react-toast, you need to put ToastContainer in a top-level component in your application. e.g. App.js

It can take some props, here's a list of them:

PropsTypeDescriptionDefault
positiontop-left | top-center | top-right | bottom-left | bottom-center | bottom-rightposition of toastbottom-left
deplay (ms)numberdelay for toast6000
Toast

There are 4 base toast type available, success, error, info and warn. For instance:

const success = () => toast.success('Message sent successfully!')

or

fetch('someRandomUrl')
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => toast.error(err.message))

Custom toast

You can display custom styled toasts, here's an example and a list of options that are available for customization:

const customToast = () =>
  toast('Morning! Have a good day.', {
    backgroundColor: '#8329C5',
    color: '#ffffff',
  })
PropertyTypeDescriptionDefault
backgroundColorstringbackground color of toastbased on toast type, e.g. success will be green
colorstringcolor of text in toast#ffffff

License

MIT

Keywords

FAQs

Last updated on 26 Apr 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc