Skip to content
caliper ui docs

Pro

JSON viewer

A collapsible tree of JSON with copy and search.

Pro
pnpm dlx shadcn@latest add @caliper/json-viewer

Webhook delivery evt_1Q9x

invoice.payment_succeeded, sent to Northwind’s billing endpoint on 20 October at 09:14

invoice.payment_succeeded
  • { 7 keys }
  • id"evt_1Q9x"
  • object"event"
  • livemodefalse
  • created1792487640
  • type"invoice.payment_succeeded"
$

Installs components/ui/json-viewer.tsxDepends on @radix-ui/react-slot, lucide-reactMotion none in component source

When to use

Use it for

  • Inspecting an API response or payload.

Skip it when

  • The data is not JSON.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/json-viewer

Adds its 5 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage

Import it from your copy of the source. The example behind the preview comes with the source.

example.tsx
import { JsonViewer } from "@/components/ui/json-viewer"

The worked example comes with Pro

The 55-line example behind the preview opens here, ready to copy.

  • 626 Pro parts, blocks and page templates, all with source
  • $149 once, with lifetime updates. No renewal
  • A full refund within 14 days if it is not for you
Checking your licence…

API reference

JsonViewer

component
PropTypeDefaultDescription
label *string—
data *unknown—
defaultDepthnumber1Levels open at first.
querystring""Highlights matching keys and values and opens the branches that hold them.
classNamestring—

Accessibility

It exposes tree, treeitem and status semantics, with aria-label, aria-level, aria-setsize, aria-posinset, aria-expanded and aria-selected kept in step with state. Changes that matter are announced through a live region.

KeyBehaviour
↓Moves to the next item or value.
↑Moves to the previous item or value.
HomeJumps to the first item or the minimum.
EndJumps to the last item or the maximum.
→Moves to the next item or value.
←Moves to the previous item or value.
EnterActivates the focused control.
SpaceActivates the focused control.

Motion

It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.

All Code & JSON examples