@@ -11,11 +11,13 @@ Here's a
11
11
12
12
Install the package:
13
13
14
- ` $ npm i -D @zerodevx/svelte-json-view `
14
+ ```
15
+ $ npm i -D @zerodevx/svelte-json-view
16
+ ```
15
17
16
18
### Svelte
17
19
18
- If you're this in a Svelte app:
20
+ If you're using this in a Svelte app:
19
21
20
22
``` html
21
23
<script >
@@ -35,18 +37,43 @@ For other applications with a bundler:
35
37
import { JsonView } from ' @zerodevx/svelte-json-view'
36
38
37
39
const app = new JsonView ({
38
- target: document .body , // node to render into
40
+ target: document .body , // node to render into
39
41
props: {
40
- json: { foo: ' bar' } // data to prettify
42
+ json: { foo: ' bar' }, // object to prettify
43
+ ... // any other props
41
44
}
42
45
})
43
46
```
44
47
45
- ## Props
48
+ Or load via CDN:
46
49
47
- ` json ` : Un-stringified object to pass in
50
+ ``` html
51
+ <head >
52
+ ...
53
+ <!-- Load `JsonView` from CDN -->
54
+ <script defer src =" https://cdn.jsdelivr.net/npm/@zerodevx/svelte-json-view@0" ></script >
55
+ <!-- Register the view -->
56
+ <script type =" module" >
57
+ window .view = new JsonView ({
58
+ target: document .querySelector (' #target' ), // node to render into
59
+ props: {
60
+ json: { foo: ' bar' }, // object to prettify
61
+ ... // any other props
62
+ }
63
+ })
64
+ </script >
65
+ </head >
66
+ <body >
67
+ <div id =" target" ></div >
68
+ </body >
69
+ ```
70
+
71
+ ## Props
48
72
49
- ` depth ` : Initial expansion depth (defaults to ` Infinity ` )
73
+ | Name | Type | Default | Description |
74
+ | ----- | ------ | -------- | -------------------------------- |
75
+ | json | Object | None | Un-stringified object to display |
76
+ | depth | Number | Infinity | Initial expansion depth |
50
77
51
78
## CSS vars
52
79
0 commit comments