File tree Expand file tree Collapse file tree 1 file changed +23
-10
lines changed Expand file tree Collapse file tree 1 file changed +23
-10
lines changed Original file line number Diff line number Diff line change
1
+ [ ![ npm (scoped)] ( https://img.shields.io/npm/v/@zerodevx/svelte-toast )] ( https://www.npmjs.com/package/@zerodevx/svelte-toast )
2
+ [ ![ JavaScript Style Guide] ( https://img.shields.io/badge/code_style-standard-brightgreen.svg )] ( https://standardjs.com )
3
+
1
4
# svelte-toast
2
5
3
6
> Simple elegant toast notifications.
4
7
8
+ A lightweight, unopinionated and performant toast notification component for modern web frontends in very little
9
+ lines of code. Compiled, it's only ** 15kb** minified (** 6kb** gzipped) and can be used in Vanilla JS, or as a
10
+ Svelte component.
11
+
5
12
Because a demo helps better than a thousand API docs: https://zerodevx.github.io/svelte-toast/
6
13
7
14
## Usage
@@ -78,18 +85,24 @@ Or if you prefer to go old-school javascript and a CDN:
78
85
``` html
79
86
<head >
80
87
...
88
+ <!-- Load `toast` and `SvelteToast` into global scope -->
89
+ <script src =" https://cdn.jsdelivr.net/npm/@zerodevx/svelte-toast@0" ></script >
90
+ <!-- Register the app -->
81
91
<script >
82
- function registerToast () {
83
- window .toastApp = new SvelteToastUMD.SvelteToast ({
84
- target: document .body
85
- });
86
- window .toast = SvelteToastUMD .toast ;
87
-
88
- // Now you can `toast` anywhere!
89
- toast .push (' Hello world!' );
90
- }
92
+ const toastApp = new SvelteToast ({
93
+ // Set where the toast container should be appended into
94
+ target: document .body ,
95
+ props: {
96
+ options: {
97
+ // Optionally set default options here
98
+ ...
99
+ }
100
+ }
101
+ })
102
+
103
+ // Now you can `toast` anywhere!
104
+ toast .push (' Hello world!' );
91
105
</script >
92
- <script defer src =" https://cdn.jsdelivr.net/npm/@zerodevx/svelte-toast@0" onload =" registerToast()" ></script >
93
106
</head >
94
107
```
95
108
You can’t perform that action at this time.
0 commit comments