Json Viewer
Collapsible JSON tree with type-colored values and per-row copy.
Import
import { JsonViewer } from "@cronus-ui/ui";
npx cronus-ui add json-viewer
Examples
.cronus
The same component declared in Cronus. Emitted at build time from the audit fixtures — the kernel renders it as HTML with no React.
default.cronus
app "audit-fixtures" {
port 5176
}
style {
preset aurora
theme dark
}
component JsonViewerDefault layout:inline style:json-viewer {
aria-label:"Payload"
label "Payload"
}
page "/audit/json-viewer/default" type:custom {
use JsonViewerDefault
}
API Reference
Generated from the component's exported types.
JsonViewerProps
Extends HTMLAttributes<HTMLDivElement>
| Prop | Type | Default | Description |
|---|---|---|---|
data* | unknown | — | The value to render. Objects and arrays become collapsible branches. |
defaultExpandedDepth | number | 1 | How many levels start expanded — a mount-time default, not a controlled value. Expansion state is uncontrolled per branch and seeded once when a branch first mounts, so later changes to this prop leave already-mounted branches untouched. The root value is depth 0, so the default of 1 shows the root's entries with every nested branch collapsed. Pass `Number.POSITIVE_INFINITY` to expand everything. |
className | string | — | Additional class names merged onto the root. |
children | ReactNode | — | Contents of the component. |
id | string | — | DOM id of the root element. |