- Accordion new
- ActionSheet new
- Alert new
- Alert Dialog new
- Angle Slider new
- Autocomplete new
- Avatar new
- Badge new
- Breadcrumb new
- Button new
- Button Group new
- Card new
- Carousel new
- Checkbox new
- Clipboard new
- Collapsible new
- Color Picker new
- Date Input new
- Date Picker new
- Dialog new
- DialogCaller new
- Drawer beta
- Editable new
- Empty new
- Field new
- Fieldset new
- File Upload new
- Filters new
- Floating Panel new
- Hover Card new
- Image new
- Image Cropper new
- Input new
- Input Group new
- Json Tree View new
- Kbd new
- Listbox new
- Marquee new
- Menu new
- Number Input new
- Pagination new
- Password Input new
- PhoneField new
- Pin Input new
- Popover new
- Progress Circular new
- Progress Linear new
- Qr Code new
- Radio Group new
- Rating Group new
- Scroll Area new
- ScrollSpy new
- Segment Group new
- Select new
- Separator new
- Sidebar new
- Signature Pad new
- Skeleton new
- Slider new
- Splitter new
- Steps new
- Switch new
- Table new
- Tabs new
- Tags Input new
- Textarea new
- Timeline new
- Timer new
- Toast new
- Toc new
- Toggle new
- Toggle Group new
- Tooltip new
- Tour new
- Tree View new
- Typography new
Json Tree View
Vue JSON tree view to explore nested objects and arrays in a collapsible, readable hierarchy.
Installation
Install from the Vuzeno registry:
bunx --bun shadcn-vue@latest add https://vuzeno.com/r/json-tree-view.json
npx shadcn-vue@latest add https://vuzeno.com/r/json-tree-view.json
yarn dlx shadcn-vue@latest add https://vuzeno.com/r/json-tree-view.json
pnpm dlx shadcn-vue@latest add https://vuzeno.com/r/json-tree-view.json
Usage
<script setup lang="ts">
import { JsonTreeView } from "@/components/ui/json-tree-view";
import { ChevronRightIcon } from "@lucide/vue";
const data = { name: "John Doe", age: 30 };
</script>
<template>
<JsonTreeView.Root :data="data" :default-expanded-depth="1">
<JsonTreeView.Tree>
<template #arrow>
<ChevronRightIcon />
</template>
</JsonTreeView.Tree>
</JsonTreeView.Root>
</template>
Composition
JsonTreeView.Root
├── JsonTreeView.RootProvider
└── JsonTreeView.Tree
Examples
Different Data Types
The JSON tree view can display various JavaScript data types including objects, arrays, primitives, and special values:
Functions and Methods
Display JavaScript functions, async functions, and generators in your JSON tree:
Regular Expressions
Regular expressions are displayed with their pattern and flags:
Error Objects
Error objects and their stack traces can be visualized:
Map and Set Objects
Native JavaScript Map and Set objects are supported:
Controlling Expand Level
Use the defaultExpandedDepth prop to control how many levels are expanded by default:
Custom Value Rendering
You can customize how specific values are rendered using the renderValue prop. This example shows how to make email addresses clickable:
Configuration Options
The JSON tree view supports several configuration options to customize the display:
<JsonTreeView.Root
:data="data"
:default-expanded-depth="2"
:quotes-on-keys="true"
:show-nonenumerable="true"
:max-preview-items="5"
:collapse-strings-after-length="50"
:group-arrays-after-length="100"
>
<JsonTreeView.Tree>
<template #arrow>
<ChevronRightIcon />
</template>
</JsonTreeView.Tree>
</JsonTreeView.Root>
Configuration Options:
quotesOnKeys: Whether to show quotes around object keysshowNonenumerable: Whether to show non-enumerable propertiesmaxPreviewItems: Maximum number of items to show in object/array previewscollapseStringsAfterLength: Collapse strings longer than this lengthgroupArraysAfterLength: Group array items when array is longer than this length
Using the Root Provider
The RootProvider component provides a context for the JSON tree view. It accepts the value of the useJsonTreeView hook. You can leverage it to access the component state and methods from outside the JSON tree view.
If you're using the
RootProvidercomponent, you don't need to use theRootcomponent.
API
See Ark UI Json Tree View docs for full props and examples.