Sortable data table
Compare structured records with sortable columns.
A collapsible JSON tree with search, paging for long arrays, and copy value or path.
npx shadcn@latest add @silicon-ui/json-viewernpx shadcn@latest add @silicon-ui/json-viewerInstall the dependencies.
npm install lucide-react motionCopy these files into your project. Shared files are skipped if you already have them.
components/silicon-ui/json-viewer/json-viewer.tsxcomponents/silicon-ui/json-viewer/json-viewer.module.cssInstall the foundation once per app for the design and motion tokens: npx shadcn@latest add @silicon-ui/silicon-foundation
| Prop | Type | Default |
|---|---|---|
data* | unknown | — |
rootNameName of the root in paths, as in `root.users[0].name`. Defaults to "root". | string | "root" |
defaultExpandDepthLevels open on first render when `defaultExpanded` is not set. Defaults to 1, which opens the root. | number | 1 |
expandedPaths of open branches. | string[] | — |
defaultExpanded | string[] | — |
onExpandedChange | (paths: string[]) => void | — |
searchableShow the search field. Defaults to true. | boolean | true |
query | string | — |
defaultQuery | string | "" |
onQueryChange | (query: string) => void | — |
pageSizeChildren shown per page in a long array or object. Defaults to 50. | number | 50 |
copyableShow copy value and copy path actions. Defaults to true. | boolean | true |
onCopy | (detail: JsonViewerCopyDetail) => void | — |
onSelectCalled when a row becomes the current one. | (detail: { path: string; value: unknown; type: JsonValueType }) => void | — |
showPathShow the path of the current row under the tree. Defaults to true. | boolean | true |
maxHeightHeight of the scrolling tree area. Defaults to 420px. | number | string | 420 |
labelAccessible name of the tree. | string | "JSON" |
className | string | — |
Also accepts the props of HTMLAttributes.