# Logs, JSON, and diffs

Source: /tuil/docs/reference/components/structured-viewers
Locale: en

Inspect streaming logs, expandable structured values, and line-oriented changes in terminal-bounded viewports.





## Overview [#overview]

Inspect streaming logs, expandable structured values, and line-oriented changes in terminal-bounded viewports.

## Installation [#installation]

<CodeBlockTabs defaultValue="npm">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="npm">
      npm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="pnpm">
      pnpm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="yarn">
      yarn
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="bun">
      bun
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="npm">
    ```bash
    npx @mwillbanks/tuil add log-viewer json-viewer diff-viewer markdown-viewer code-viewer timeline bar-chart structured-content rich-diff-viewer
    ```
  </CodeBlockTab>

  <CodeBlockTab value="pnpm">
    ```bash
    pnpm dlx @mwillbanks/tuil add log-viewer json-viewer diff-viewer markdown-viewer code-viewer timeline bar-chart structured-content rich-diff-viewer
    ```
  </CodeBlockTab>

  <CodeBlockTab value="yarn">
    ```bash
    yarn dlx @mwillbanks/tuil add log-viewer json-viewer diff-viewer markdown-viewer code-viewer timeline bar-chart structured-content rich-diff-viewer
    ```
  </CodeBlockTab>

  <CodeBlockTab value="bun">
    ```bash
    bun x @mwillbanks/tuil add log-viewer json-viewer diff-viewer markdown-viewer code-viewer timeline bar-chart structured-content rich-diff-viewer
    ```
  </CodeBlockTab>
</CodeBlockTabs>

The CLI writes source-owned components beneath the destination configured in
`tuil.config.ts`; the default import below assumes `src/components/tuil`.

<PublishedStory storyId="component-acceptance" variant="LogViewer" />

## Components and subcomponents [#components-and-subcomponents]

| API                                                                                                    | Signature                           | Description                               |
| ------------------------------------------------------------------------------------------------------ | ----------------------------------- | ----------------------------------------- |
| [`LogViewer`](/tuil/docs/reference/components/structured-viewers/log-viewer)                                | `function LogViewer`                | Public function LogViewer.                |
| [`JsonViewer`](/tuil/docs/reference/components/structured-viewers/json-viewer)                              | `function JsonViewer`               | Public function JsonViewer.               |
| [`flattenJson`](/tuil/docs/reference/components/structured-viewers/flatten-json)                            | `function flattenJson`              | Public function flattenJson.              |
| [`DiffViewer`](/tuil/docs/reference/components/structured-viewers/diff-viewer)                              | `function DiffViewer`               | Public function DiffViewer.               |
| [`createLineDiff`](/tuil/docs/reference/components/structured-viewers/create-line-diff)                     | `function createLineDiff`           | Public function createLineDiff.           |
| [`MarkdownViewer`](/tuil/docs/reference/components/structured-viewers/markdown-viewer)                      | `function MarkdownViewer`           | Public function MarkdownViewer.           |
| [`CodeViewer`](/tuil/docs/reference/components/structured-viewers/code-viewer)                              | `function CodeViewer`               | Public function CodeViewer.               |
| [`Timeline`](/tuil/docs/reference/components/structured-viewers/timeline)                                   | `function Timeline`                 | Public function Timeline.                 |
| [`BarChart`](/tuil/docs/reference/components/structured-viewers/bar-chart)                                  | `function BarChart`                 | Public function BarChart.                 |
| [`StructuredContentSummary`](/tuil/docs/reference/components/structured-viewers/structured-content-summary) | `function StructuredContentSummary` | Public function StructuredContentSummary. |
| [`RichDiffViewer`](/tuil/docs/reference/components/structured-viewers/rich-diff-viewer)                     | `function RichDiffViewer`           | Public function RichDiffViewer.           |

## Interaction [#interaction]

Viewers scroll and filter; JSON nodes expand or collapse; diff output remains deterministic in static mode.

## API and events [#api-and-events]

`LogViewer` reports follow state; JSON expansion can be controlled; pure transformation helpers emit nothing.

Every interactive component publishes semantic roles, labels, state, and focus
identity through the renderer's `SemanticRegistry`. Callback failures flow to
the owning application's error boundary.

<Mermaid
  chart="flowchart LR
  S0[&#x22;props and runtime state&#x22;]
  S1[&#x22;semantic registration&#x22;]
  S2[&#x22;focus and input routing&#x22;]
  S3[&#x22;callback or state update&#x22;]
  S4[&#x22;rerender&#x22;]
  S0 --> S1
  S1 --> S2
  S2 --> S3
  S3 --> S4"
/>

## Example [#example]

```tsx
import type { ComponentProps } from "react";
import { LogViewer } from "@/components/tuil/data-display/log-viewer";

export function Example(props: ComponentProps<typeof LogViewer>) {
  return <LogViewer {...props} />;
}
```

Registry-installed components are source-owned: customize the generated file in
your application, and use the package reference for the shared runtime contracts.
