Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Collections

  • QuestionCard
  • Table
  • Book3D
  • ProTable
  • PricingTable
  • JsonViewer
  • EditableTable
  • List
  • Descriptions
  • RowActions
  • Tree
  • Card
  • Carousel
  • Video
  • Audio
  • BentoGrid
  • Image
  • MagicCard
  • AnimatedList
  • Marquee
  • Sortable
  • Kanban
  • DesignCanvas
  • LayerTree
  • StageDraw
  • SlideDeck
  • PresenterView
  • ComponentPicker
  • EventStream
  • QueueLane
  • DocumentSheet
  • Novel reader
  • Scheduler
  • Org classroom
  • Danmaku
  • LiveChat
  • LivePlayer
  • LogViewer
  • FileTree
  • CodeReviewThread
  • VirtualList
  • InfiniteScroll
  • LogoLoop
  • BounceCards
  • CardSwap
  • ChromaGrid
  • CircularGallery
  • DomeGallery
  • FlyingPosters
  • InfiniteMenu
  • MagicBento
  • ScrollStack
  • ProfileCard
  • TiltedCard
  • PixelCard
  • DecayCard
  • ReflectiveCard
  • Folder

Charts and Diagrams

  • Flow
  • Diagram
  • Paper
  • SequenceDiagram
  • Sankey
  • Sparkline
  • Funnel
  • Treemap
  • Gantt
  • Heatmap
  • ContributionGraph
  • Legend
  • Chart
  • WorldMap

Information

  • ImageViewer
  • LiveProductCard
  • DiffStat
  • ScoreRing
  • ScoreScale
  • Badge
  • Dot
  • StatusDot
  • Chip
  • FilterChip
  • Coupon
  • Tag
  • Annotation
  • Avatar
  • AvatarCircles
  • User
  • QRCode
  • Comment
  • RelativeTime
  • GitCommit
  • DeployStatus
  • ShieldBadge
  • AwardBadge
  • CreditCard
  • IconTile

Metrics

  • Stat
  • Statistic
  • Meter
  • Timeline
  • NumberTicker

Placeholders

  • Empty
  • Skeleton
  • Watermark

JsonViewer

json-viewer

Inspects collapsible JSON values with syntax coloring, copying, and depth controls.

Usage

Basic usage

Passing data will render the foldable JSON tree, and the first layer will be expanded by default.

id:"chatcmpl-9hk2f7"
object:"chat.completion"
model:"claude-opus-4-7"
created:1749100800
tsx
<JsonViewer data={response} />

Control the initial expansion depth

defaultExpandedDepth controls the initial expansion level (root direct child node depth=1).

prompt_tokens:128
completion_tokens:42
total_tokens:170
cost_usd:0.00169
tsx
<JsonViewer data={response.usage} defaultExpandedDepth={3} />

Copy node path

onCopyPath returns the node JSON path when copying on hover; rootName determines the path prefix (e.g. $.response.usage).

id:"chatcmpl-9hk2f7"
object:"chat.completion"
model:"claude-opus-4-7"
created:1749100800
tsx
<JsonViewer
  data={response}
  rootName="response"
  onCopyPath={(path) => console.log(path)}
/>

When to use

Use JsonViewer to inspect arbitrary nested JSON in gateway logs, API debuggers, or configuration previews. Use Descriptions for flat key-value details. JsonViewer is read-only and designed for deep trees.

Import

ts
import { JsonViewer, valueType, jsonPath } from "@hulianui/ui"

Props

NameTypeDefaultDescription
data*unknown-Any JSON-compatible value.
rootNamestring-Optional root label such as "response".
defaultExpandedDepthnumber1Nodes expand initially when depth < defaultExpandedDepth; direct root children have depth 1.
maxAutoExpandKeysnumber50Child-count threshold above which an object or array starts collapsed.
classNamestring-Root class name.

Events

EventTypeDescription
onCopyPath(path: string) => voidCalled after copying a node value and its JSON path.

Usage notes

  • JsonViewer is read-only. onCopyPath reports copying and never changes data.
  • Objects with more than maxAutoExpandKeys children start collapsed for performance; expand them manually.
  • The copy control uses built-in Chinese "\u590d\u5236" (“Copy”) and changes to "\u5df2\u590d\u5236" (“Copied”).

Related

Table · Book3D · ProTable · PricingTable · EditableTable · List

Playground

id:"chatcmpl-9hk2f7"
object:"chat.completion"
model:"claude-opus-4-7"
created:1749100800
<JsonViewer data={response} defaultExpandedDepth={1} />
PreviousPricingTableData DisplayNextEditableTable

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Usage notes
    • Related
  • Playground