Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/w99910/vanilla-toaster
https://github.com/w99910/vanilla-toaster
Last synced: about 13 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/w99910/vanilla-toaster
- Owner: w99910
- License: mit
- Created: 2024-03-04T09:03:56.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-03-04T09:27:47.000Z (11 months ago)
- Last Synced: 2024-12-28T00:09:39.716Z (30 days ago)
- Language: TypeScript
- Size: 6.61 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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);
```