@@ -11,11 +11,13 @@ Here's a
1111
1212Install the package:
1313
14- ` $ npm i -D @zerodevx/svelte-json-view `
14+ ```
15+ $ npm i -D @zerodevx/svelte-json-view
16+ ```
1517
1618### Svelte
1719
18- If you're this in a Svelte app:
20+ If you're using this in a Svelte app:
1921
2022``` html
2123<script >
@@ -35,18 +37,43 @@ For other applications with a bundler:
3537import { JsonView } from ' @zerodevx/svelte-json-view'
3638
3739const app = new JsonView ({
38- target: document .body , // node to render into
40+ target: document .body , // node to render into
3941 props: {
40- json: { foo: ' bar' } // data to prettify
42+ json: { foo: ' bar' }, // object to prettify
43+ ... // any other props
4144 }
4245})
4346```
4447
45- ## Props
48+ Or load via CDN:
4649
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
4872
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 |
5077
5178## CSS vars
5279
0 commit comments