# Version history

Browse document revisions, inspect changes and request restoration explicitly.

Access: pro. Category: Blocks. Kind: composite.

## When to use

- Use it when a page needs browse document revisions, inspect changes and request restoration explicitly.
- Choose it inside an authenticated product surface when the host application owns routing, persistence, and service calls.

## Alternatives

- Choose empty-state instead when empty collections, search results and errors with a clear next action is the actual interface need, rather than version history.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Version history

```sh
npx shadcn@latest add @tidal-pro/version-history
```

Stylesheets: `components/ui/tidal.css`, `components/ui/version-history.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/version-history.css";
import{TidalVersionHistory}from"./components/ui/version-history";
export default()=><div className="tidal-scope"><TidalVersionHistory title={"Demo"} versions={[{id:"example",label:"Demo",author:"value",time:{label:"Demo"}}]}/></div>;
```

## Structured props

- `TidalVersionHistory.title: ReactNode`: Required title value accepted by this exported component.
- `TidalVersionHistory.versions: ReadonlyArray<TidalVersionEntry>`: Required versions value accepted by this exported component.
- `TidalVersionHistory.confirmation?: ReactNode`: Optional confirmation value accepted by this exported component.
- `TidalVersionHistory.currentVersionId?: string | undefined`: Optional current version id value accepted by this exported component.
- `TidalVersionHistory.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalVersionHistory.emptyContent?: ReactNode` (default "No versions available."): Optional empty content value accepted by this exported component.
- `TidalVersionHistory.headingLevel?: "h2" | "h3" | "h4" | "h5" | "h6" | undefined` (default "h2"): Optional heading level value accepted by this exported component.
- `TidalVersionHistory.labels?: { current?: string; viewing?: string; changes?: string; preview?: string; restore?: string; restoring?: string; list?: string; open?: string; } | undefined` (default {}): Optional labels value accepted by this exported component.
- `TidalVersionHistory.onPreviewRequest?: ((version: TidalVersionEntry, event: MouseEvent<HTMLButtonElement>) => void) | undefined`: Callback invoked when the preview request interaction is proposed.
- `TidalVersionHistory.onRestoreRequest?: ((version: TidalVersionEntry, event: MouseEvent<HTMLButtonElement>) => void) | undefined`: Callback invoked when the restore request interaction is proposed.
- `TidalVersionHistory.pendingVersionId?: string | undefined`: Optional pending version id value accepted by this exported component.
- `TidalVersionHistory.preview?: ReactNode`: Optional preview value accepted by this exported component.
- `TidalVersionHistory.selectedVersionId?: string | undefined`: Optional selected version id value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/version-history.tsx) | [Manifest](https://tidalui.com/examples/version-history.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { useRef, useState } from "react";

import { TidalVersionHistory, type TidalVersionEntry } from "./components/ui/version-history";

import { TidalAlertDialog } from "./components/ui/alert-dialog";

import "./components/ui/version-history.css";

import "./components/ui/alert-dialog.css";

import "./components/ui/status-badge.css";

import "./components/ui/collapsible-panel.css";



const tidalExampleStyles = ".tidal-scope .version-history-demo {\n  width: 100%;\n  max-width: 680px;\n  min-width: 0;\n}\n.tidal-scope .version-history-demo > p {\n  font-size: 11px;\n  color: var(--t-muted);\n  line-height: 1.5;\n  margin: 12px 0 0;\n}";

const revisions = [
  {
    id: "v3",
    label: "Version 3",
    author: "Alex Morgan",
    time: { label: "Today, 10:30 AM", dateTime: "2026-10-14T10:30:00Z" },
    summary: "Shortened the introduction and added release dates.",
    changes: "Updated the opening paragraph and release schedule.",
    content: "A simpler release notes page. Find every update in one place.",
  },
  {
    id: "v2",
    label: "Version 2",
    author: "Sam Lee",
    time: { label: "Yesterday, 3:45 PM", dateTime: "2026-10-13T15:45:00Z" },
    summary: "Added the product overview.",
    changes: "Added a summary of the product and its current features.",
    content: "Release notes for the product team. Read the latest changes.",
  },
  {
    id: "v1",
    label: "Version 1",
    author: "Alex Morgan",
    time: { label: "October 12, 9:00 AM", dateTime: "2026-10-12T09:00:00Z" },
    summary: "Created the first draft.",
    content: "Product release notes.",
  },
];

export function VersionHistoryDemo({
  theme = "light",
}: {
  theme?: "light" | "dark";
}) {
  const [current, setCurrent] = useState("v3"),
    [selected, setSelected] = useState("v3"),
    [request, setRequest] = useState<TidalVersionEntry | null>(null),
    [message, setMessage] = useState("Sample document history.");
  const opener = useRef<HTMLButtonElement | null>(null);
  const previewRefs = useRef<Record<string, HTMLButtonElement | null>>({});
  return (
    <div className="version-history-demo">
      <TidalVersionHistory
        title="Version history"
        description="Release notes page"
        versions={revisions.map((v) => ({
          ...v,
          previewButtonRef: (node: HTMLButtonElement | null) => {
            previewRefs.current[v.id] = node;
          },
        }))}
        currentVersionId={current}
        selectedVersionId={selected}
        onPreviewRequest={(v) => setSelected(v.id)}
        onRestoreRequest={(v, e) => {
          opener.current = e.currentTarget;
          setRequest(v);
        }}
        preview={
          <>
            <strong>
              Document preview ·{" "}
              {revisions.find((v) => v.id === selected)?.label}
            </strong>
            <p>{revisions.find((v) => v.id === selected)?.content}</p>
          </>
        }
        confirmation={
          <TidalAlertDialog
            open={request !== null}
            onOpenChange={(open) => {
              if (!open) setRequest(null);
            }}
            trigger={
              <button type="button" hidden tabIndex={-1}>
                Restore version
              </button>
            }
            title={`Restore ${request?.label ?? "version"}?`}
            description="This changes the current version in this local preview."
            cancelLabel="Cancel"
            confirmLabel="Restore version"
            onCancel={() => setRequest(null)}
            onConfirm={() => {
              if (request) {
                setCurrent(request.id);
                setSelected(request.id);
                setMessage(`${request.label} is current in this preview.`);
              }
              setRequest(null);
            }}
            theme={theme}
            contentProps={{
              onCloseAutoFocus: (event) => {
                event.preventDefault();
                const target = opener.current?.isConnected
                  ? opener.current
                  : previewRefs.current[selected];
                target?.focus({ preventScroll: true });
              },
            }}
          />
        }
      />
      <p role="status">{message}</p>
      <p>Sample data. No document is saved.</p>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <VersionHistoryDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Consumer-owned ordered versions require unique id, label, author and exact time label with optional dateTime. Optional summary, Changes disclosure, native href/link props/ref, disabled, preview/restore button props/refs. Optional currentVersionId, selectedVersionId, pendingVersionId, preview and confirmation slots; bounded headingLevel and native section props/ref. Restore is absent for the current version; a pending ID disables restoration requests and marks the matching action busy. Native caller handlers run before callbacks and can prevent them; native/ARIA disabled states normalize, including unavailable links with no href and suppressed click handlers. Callbacks only request preview/restore; the consumer owns confirmation, current version, history, errors, storage and actual restoration. No data mutation or history ordering is invented.
