Live preview

Interactive example

Loading example…

Usage

Import the component and its manager, then make it your own.

ComponentJson
Managercreate_json_manager

svelte

<script>
  // Import the shared stylesheet once in your application's root layout.
  import "sveltekit-ui/style.css"
  import { Json, create_json_manager } from "sveltekit-ui"

  const manager = create_json_manager({
    label: "Project settings",
    val: { name: "Website", published: false, tags: ["svelte", "ui"] },
    is_edit_mode: true,
    is_show_buttons: true,
  })
</script>

<Json {manager} />
<pre>{JSON.stringify(manager.val, null, 2)}</pre>

API reference

Configure the manager, call its methods, and read its reactive state.

7 entries in configuration

PropertyTypeDefaultDescription
valany nullthe initial json object/array/value to display or edit
is_popoverboolean falseif true, the json viewer/editor is placed in a popover
is_edit_modeboolean falseif true, displays editing controls (upload, full-edit popover, etc.)
is_show_buttonsboolean falseif true, shows collapse, expand, copy, etc. buttons in the interface
labelstring nulloptional label text to show above the json viewer
indentationnumber 1indentation or nesting offset for the displayed structure
on_finishfunction nullcalled when the user taps the 'finish' button in the popover, receives the final json value