Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/w99910/vanilla-toaster


https://github.com/w99910/vanilla-toaster

Last synced: about 13 hours ago
JSON representation

Awesome Lists containing this project

README

        

# Vanilla Toaster

Toast messages globally anywhere inside your app with a single static method.

> AnimeJs is used for handling animation.

## Installation

Import via NPM.

```bash
npm install vanilla-toaster
```

Or import from CDN `https://cdn.jsdelivr.net/npm/vanilla-toaster@latest/dist/vanilla-toaster.js`.

```js
import Toaster from 'https://cdn.jsdelivr.net/npm/vanilla-toaster@latest/dist/vanilla-toaster.js';
```

## Usage

### Initialization

```js
import Toaster from 'vanilla-toaster';

const toaster = document.createElement('div');
document.body.appendChild(toaster);
new Toaster(toaster);
```

### Toast anywhere

```js
import Toaster from 'vanilla-toaster';

Toaster.toast('Hello World!');
```

### Customizing

- Select toast type - `info`, `success`, `warning`, `error`.

```js
Toaster.toast('Hello World!', 'success');
```

- Provide Toast Duration in milliseconds. Default is `2000`. (2 seconds)

```js
Toaster.toast('Hello World!', 'success', 5000);
```