Skip to content

Commit 990c3f8

Browse files
committed
docs: ✏️ Installation & usage
1 parent f9a3c95 commit 990c3f8

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,62 @@
22

33
> Lightweight toast-notification plugin for Vue 3
44
5+
## Installation
6+
7+
```bash
8+
npm install @meforma/vue-toaster
9+
```
10+
11+
## Usage
12+
13+
Import in your main.js
14+
15+
```js
16+
import Toaster from "@incuca/vue3-toaster";
17+
18+
createApp(App)
19+
.use(Toaster)
20+
.mount("#app");
21+
```
22+
23+
Usage in your components with Options API
24+
25+
```js
26+
this.$toast.show(message, { ...options });
27+
this.$toast.success(`Hey! I'm here`);
28+
this.$toast.error(`Hey! I'm here`);
29+
this.$toast.warning(`Hey! I'm here`);
30+
this.$toast.info(`Hey! I'm here`);
31+
// Close all opened toasts after 3000ms
32+
setTimeout(this.$toast.clear, 3000);
33+
```
34+
35+
Usage with Composition API
36+
37+
```js
38+
import { inject } from "vue";
39+
const toast = inject("toast");
40+
toast.show(message, { ...options });
41+
```
42+
43+
## Available options
44+
45+
The API methods accepts these options:
46+
47+
| Attribute | Type | Default | Description |
48+
| :------------ | :--------------: | :------------: | :---------------------------------------------------------------------------- |
49+
| message | String | -- | Message text/html (required) |
50+
| type | String | `default` | `success`, `info`, `warning`, `error` or `default` |
51+
| position | String | `bottom-right` | `top`, `bottom`, `top-right`, `bottom-right`,`top-left` or `bottom-left` |
52+
| duration | Number/Boolean | `4000` | Visibility duration in milliseconds or `false` that disables duration |
53+
| dismissible | Boolean | `true` | Allow user close by clicking |
54+
| onClick | Function | -- | Do something when user clicks |
55+
| onClose | Function | -- | Do something after toast gets dismissed |
56+
| queue | Boolean | `false` | Wait for existing to close before showing new |
57+
| maxToasts | Number/Boolean | `false` | Defines the max of toasts showed in simultaneous |
58+
| pauseOnHover | Boolean | `true` | Pause the timer when mouse hover a toast |
59+
| useDefaultCss | Boolean | `true` | Use default css styles |
60+
561
## License
662

763
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@incuca/vue-toaster",
2+
"name": "@incuca/vue3-toaster",
33
"version": "1.0.0",
44
"description": "Lightweight toast-notification plugin for Vue 3",
55
"license": "MIT",

0 commit comments

Comments
 (0)