JSPM

  • Created
  • Published
  • Downloads 3869
  • Score
    100M100P100Q123866F
  • License MIT

Simple toast popup for React

Package Exports

  • react-simple-toasts
  • react-simple-toasts/dist/index.es.js
  • react-simple-toasts/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-simple-toasts) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-simple-toasts

Simple toast message popup for React ⚛️

NPM JavaScript Style Guide

Install

npm install --save react-simple-toasts

Usage

a very simple use

toast(message);
// or
toast(message, (millisecond = 3000));
// or
toast(message, { time: 3000, ...options });
import React from 'react';
import toast from 'react-simple-toasts';

const Example = () => (
  <div className="example">
    <button onClick={() => toast('Hello toast!')}>Toast</button>
    <button onClick={() => toast('Message', 1000)}>One-second</button>
  </div>
);

Live Demo

Options

Name Type Default Description
time number 3000 The millisecond time that the message is displayed
className string '' Can be used to customize styles
clickable string false Can click the message
clickClosable boolean false Whether to close the toast when is clicked
render (message: string) => ReactNode null Renderer of the toast. The return value should be a ReactNode
onClick (event) => void Set the handler to handle click event
Must be used with clickable: true

Config Defaults

You can specify config defaults.

index.js

import { toastConfig } from 'react-simple-toasts';

toastConfig({
  time: 5000,
  className: 'my-toast-message',
});
Name Type Default Description
time number 3000 The millisecond time that the message is displayed.
className string '' Can be used to customize styles.
position string center left, center, right
clickClosable boolean false Whether to close the toast when is clicked
render (message: string) => ReactNode null Renderer of the toast. The return value should be a ReactNode


Thanks

Support it by joining stargazers for this repository. ⭐

License

MIT © almond-bongbong