TidalUI

JSON viewer preview

Inspect valid JSON as a searchable keyboard tree or exact read-only source with paths and consumer-owned copy actions.

pro · Data · composite

When to use

Alternatives

Configure components.json and the @tidal-pro namespace before installing Pro components.

Installation

npx shadcn@latest add @tidal-pro/json-viewer

Import components/ui/tidal.css, components/ui/json-viewer.css. Wrap installed components in tidal-scope.

Preview

JSON viewer component preview

Open interactive preview

Minimal example

import"./components/ui/tidal.css";
import"./components/ui/json-viewer.css";
import{TidalJsonViewer}from"./components/ui/json-viewer";
export default()=><div className="tidal-scope"><TidalJsonViewer expandedPaths={["value"]} label={"Demo"} onExpandedPathsChange={() => {}} onSelectedPathChange={() => {}} onViewChange={() => {}} selectedPath={"value"} value={"value"} view={"source"}/></div>;

API and props

TidalJsonViewer.expandedPaths (required)
ReadonlyArray<string>

Required expanded paths value accepted by this exported component.

TidalJsonViewer.label (required)
string

Required label value accepted by this exported component.

TidalJsonViewer.onExpandedPathsChange (required)
(paths: readonly string[], path: string, value: TidalJsonValue, event: TidalTreeInteractionEvent | MouseEvent<HTMLButtonElement>) => void

Callback invoked when the expanded paths change interaction is proposed.

TidalJsonViewer.onSelectedPathChange (required)
(path: string, value: TidalJsonValue, event: TidalTreeInteractionEvent) => void

Callback invoked when the selected path change interaction is proposed.

TidalJsonViewer.onViewChange (required)
(view: TidalJsonView, event: MouseEvent<HTMLButtonElement>) => void

Callback invoked when the view change interaction is proposed.

TidalJsonViewer.selectedPath (required)
string | null

Required selected path value accepted by this exported component.

TidalJsonViewer.value (required)
TidalJsonValue

Required value value accepted by this exported component.

TidalJsonViewer.view (required)
TidalJsonView

Required view value accepted by this exported component.

TidalJsonViewer.copyButtonProps
NativeButtonProps | undefined

Optional copy button props value accepted by this exported component.

TidalJsonViewer.copyButtonRef
Ref<HTMLButtonElement> | undefined

Optional copy button ref value accepted by this exported component.

TidalJsonViewer.description
ReactNode

Optional description value accepted by this exported component.

TidalJsonViewer.dir
"ltr" | "rtl" | undefined

Optional dir value accepted by this exported component.

TidalJsonViewer.disabled
boolean | undefined

Optional disabled value accepted by this exported component.

TidalJsonViewer.headingLevel
TidalJsonHeadingLevel | undefined

Optional heading level value accepted by this exported component.

TidalJsonViewer.labels
Partial<TidalJsonViewerLabels> | undefined

Optional labels value accepted by this exported component.

TidalJsonViewer.maxStringLength
number | undefined

Optional max string length value accepted by this exported component.

TidalJsonViewer.onCopyRequest
((request: TidalJsonCopyRequest, event: MouseEvent<HTMLButtonElement>) => void) | undefined

Callback invoked when the copy request interaction is proposed.

TidalJsonViewer.onQueryChange
((query: string, event: ChangeEvent<HTMLInputElement>) => void) | undefined

Callback invoked when the query change interaction is proposed.

TidalJsonViewer.query
string | undefined

Optional query value accepted by this exported component.

TidalJsonViewer.searchInputProps
SearchInputProps | undefined

Optional search input props value accepted by this exported component.

TidalJsonViewer.searchInputRef
Ref<HTMLInputElement> | undefined

Optional search input ref value accepted by this exported component.

TidalJsonViewer.sourceButtonProps
NativeButtonProps | undefined

Optional source button props value accepted by this exported component.

TidalJsonViewer.sourceButtonRef
Ref<HTMLButtonElement> | undefined

Optional source button ref value accepted by this exported component.

TidalJsonViewer.sourceMaxHeight
number | undefined

Optional source max height value accepted by this exported component.

TidalJsonViewer.treeButtonProps
NativeButtonProps | undefined

Optional tree button props value accepted by this exported component.

TidalJsonViewer.treeButtonRef
Ref<HTMLButtonElement> | undefined

Optional tree button ref value accepted by this exported component.

TidalJsonViewer.treeRef
Ref<HTMLDivElement> | undefined

Optional tree ref value accepted by this exported component.

Complete usage

Full example, stylesheet imports, API and accessibility documentation

Gotchas