# react-toastbox

> A minimal react toast box inspired by reddit's toast message design and react-toastify.

Latest version **1.2.6** (published 2019-12-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-toastbox
pnpm add react-toastbox
yarn add react-toastbox
bun add react-toastbox
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.6 |
| Published | 2019-12-12 |
| First published | 2019-12-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 38.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Meet Zaveri |
| Maintainers | meetzaveri |
| Keywords | react, notification, toast, react-component, react-toastbox, push, alert |

## Links

- npm: https://www.npmjs.com/package/react-toastbox
- Repository: https://github.com/meetzaveri/react-toastbox
- Homepage: https://github.com/meetzaveri/react-toastbox#readme
- Issues: https://github.com/meetzaveri/react-toastbox/issues
- npm.io page: https://npm.io/package/react-toastbox

## Dependencies (6)

- [react](https://npm.io/package/react.md) 16.8.6
- [node-sass](https://npm.io/package/node-sass.md) ^4.13.0
- [react-dom](https://npm.io/package/react-dom.md) 16.8.6
- [classnames](https://npm.io/package/classnames.md) 2.2.6
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2
- [react-scripts](https://npm.io/package/react-scripts.md) 3.0.1

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 1.2.6 (latest) — 2019-12-12
- 1.2.5 — 2019-12-08
- 1.2.4 — 2019-12-08
- 1.2.3 — 2019-12-06
- 1.2.2 — 2019-12-05
- 1.2.1 — 2019-12-05
- 1.2.0 — 2019-12-05
- 1.1.9 — 2019-12-05
- 1.1.8 — 2019-12-05
- 1.1.7 — 2019-12-05
- 1.1.6 — 2019-12-04
- 1.1.5 — 2019-12-04
- 1.1.4 — 2019-12-04
- 1.1.3 — 2019-12-04
- 1.1.2 — 2019-12-04
- … 12 more at https://npm.io/package/react-toastbox/versions

## README

# react-toastbox

A minimal react toast box inspired by reddit's toast message design and react-toastify.

## Installation

[![NPM version](https://img.shields.io/badge/npm-1.2.6-brightgreen.svg)](https://www.npmjs.com/package/react-toastbox)

Using npm:

```
npm install react-toastbox
```

## Codesandbox demo

[Live Demo](https://codesandbox.io/s/epic-currying-62r0y)

## Screenshots

![Toaster](https://i.imgur.com/5CDEUf9.png)

## API

### props

<table class="table table-bordered table-striped">
  <thead>
  <tr>
    <th style="width: 60px;">name</th>
    <th style="width: 50px;">type</th>
    <th style="width: 10px;">default</th>
    <th>description</th>
  </tr>
  </thead>
  <tbody>
    <!-- <tr>
      <td>textContent</td>
      <td>String</td>
      <td>'Your message here'</td>
      <td>To display text content</td>
    </tr> -->
    <tr>
      <td>timerExpires</td>
      <td>Number</td>
      <td>6000(in 'ms')</td>
      <td>Expiration time till toast message should be visible</td>
    </tr>
    <tr>
      <td>pauseOnHover</td>
      <td>Boolean</td>
      <td>true</td>
      <td>On hovering toast, it's timer should be paused</td>
    </tr>
    <tr>
      <td>position</td>
      <td>String</td>
      <td>'top-right'</td>
      <td>Position for toast to be displayed.</td>
    </tr>
    <tr>
      <td>intent</td>
      <td>String</td>
      <td>'primary'</td>
      <td> Theme for toast message </td>
    </tr>
  </tbody>
</table>

## Possible values for API

```js
positionClasses = [
  "top-right",
  "top-left",
  "top-center",
  "bottom-right",
  "bottom-left",
  "bottom-center"
];
paints = ["success", "warning", "danger"];
```

## Quick API tour

In order to use toast box, you need to define component `<ToastBox/>` in root file which will listen for events(success,danger,etc), for example i.e. `App.js`.

Then when you want to show `error` or `success` message, just use `{toast}` method available from package. `toast.success('Yayy')`

### ToastBox

```js
import ToastBox from "react-toastbox";
.
.
.
<ToastBox timerExpires={5000} position="top-right" pauseOnHover={true} intent="success"/>

```

### { toast }

```js
import { toast } from "react-toastbox";
.
.
.
handleClick = () => {
  /* Then when you want to show toast, call method and pass argument as text to display*/
  toast.success('Toast it up');
}
```

## Usage

- Use `<ToastBox />` once in your app which listens to events such as success,error,etc...
  So in your root component(mainly `App.js` or `main.js`), register this component with suitable props acc. to your needs

#### Parent (App.js)

```js
import React from "react";
import ToastBox from "react-toastbox";

/* Your root app logic here */
.
.
.
 <ToastBox
    timerExpires={5000}
    position="top-right"
    pauseOnHover={true}
  />


```

- Then you can call any methods such as `success`,`error`,etc... from your `children`. The `<ToastBox />` will listen to event and propagate changes.

#### Child(childToRender.js)

```js
import React from "react";
import { toast } from "react-toastbox";

function Child() {
  return (
    <div className="App">
      <button
        onClick={() => {
          /* Then when you want to show toast, call method and pass argument as text to display*/
          toast.success("Toast it up");
        }}
      >
        Show me toast
      </button>
    </div>
  );
}
export default Child;
```

In Nutshell,

```js
import React from "react";
import ReactDOM from "react-dom";
import ToastBox, { toast } from "react-toastbox";
import "./styles.css";

function App() {
  return (
    <div className="App">
      {/* First define toastbox component which will listen to events*/}
      <ToastBox
        timerExpires={5000}
        position="top-right"
        pauseOnHover={true}
        intent="success"
      />
      <button
        onClick={() => {
          /* Then when you want to show toast, call method and pass argument as text to display*/
          toast.success("Toast it up");
        }}
      >
        Show me toast
      </button>
    </div>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
```

---
_Source: https://npm.io/package/react-toastbox · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
