# Audit log

Review consumer-supplied actor, action, resource and time records with controlled filters and before-and-after detail.

Access: pro. Category: Data. Kind: composite.

## When to use

- Use it when a page needs review consumer-supplied actor, action, resource and time records with controlled filters and before-and-after detail.
- Choose it when the data structure, labels, and state are supplied by the application and must remain consumer controlled.

## Alternatives

- Choose data-table instead when sortable column controls, native row selection and a scrollable table is the actual interface need, rather than audit log.

## 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 Audit log

```sh
npx shadcn@latest add @tidal-pro/audit-log
```

Stylesheets: `components/ui/tidal.css`, `components/ui/audit-log.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/audit-log.css";
import{TidalAuditLog}from"./components/ui/audit-log";
export default()=><div className="tidal-scope"><TidalAuditLog events={[{id:"example",actor:{name:"Demo"},action:"#",resource:{label:"Demo",href:"#"},dateTime:"2026-01-01",timeLabel:"Demo"}]} summary={"Demo"} timezoneLabel={"Demo"} title={"Demo"}/></div>;
```

## Structured props

- `TidalAuditLog.events: ReadonlyArray<TidalAuditEvent>`: Required events value accepted by this exported component.
- `TidalAuditLog.summary: ReactNode`: Required summary value accepted by this exported component.
- `TidalAuditLog.timezoneLabel: ReactNode`: Required timezone label value accepted by this exported component.
- `TidalAuditLog.title: ReactNode`: Required title value accepted by this exported component.
- `TidalAuditLog.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalAuditLog.emptyContent?: ReactNode`: Optional empty content value accepted by this exported component.
- `TidalAuditLog.eventHeadingLevel?: "h3" | "h4" | "h5" | "h6" | undefined`: Optional event heading level value accepted by this exported component.
- `TidalAuditLog.exportAction?: TidalAuditExportAction | undefined`: Optional export action value accepted by this exported component.
- `TidalAuditLog.filters?: ReadonlyArray<TidalAuditFilter> | undefined` (default []): Optional filters value accepted by this exported component.
- `TidalAuditLog.footer?: ReactNode`: Optional footer value accepted by this exported component.
- `TidalAuditLog.headingLevel?: "h2" | "h3" | "h4" | "h5" | undefined` (default "h2"): Optional heading level value accepted by this exported component.
- `TidalAuditLog.labels?: Partial<TidalAuditLogLabels> | undefined`: Optional labels value accepted by this exported component.
- `TidalAuditLog.listProps?: Omit<HTMLAttributes<HTMLDivElement>, "aria-disabled" | "children" | "dangerouslySetInnerHTML"> | undefined` (default {}): Optional list props value accepted by this exported component.
- `TidalAuditLog.listRef?: Ref<HTMLDivElement> | undefined`: Optional list ref value accepted by this exported component.

## Complete usage example

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

```tsx
"use client";

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

import { useId, useMemo, useState, type MouseEvent } from "react";

import { TidalAuditLog, type TidalAuditEvent, type TidalAuditFilter, type TidalAuditLinkedResource } from "./components/ui/audit-log";

import "./components/ui/audit-log.css";



const tidalExampleStyles = ".audit-demo,\n.audit-demo * {\n  box-sizing: border-box;\n}\n\n.audit-demo {\n  container: audit-demo / inline-size;\n  display: grid;\n  width: 100%;\n  max-width: 780px;\n  min-width: 0;\n  gap: 12px;\n}\n\n.audit-demo-status,\n.audit-demo-boundary,\n.audit-demo-resources p {\n  min-width: 0;\n  margin: 0;\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.5;\n  overflow-wrap: anywhere;\n}\n\n.audit-demo-status {\n  min-height: 34px;\n  padding: 8px 11px;\n  border: 1px solid var(--t-border);\n  border-radius: var(--t-radius-control);\n  background: var(--t-subtle);\n}\n\n.audit-demo-resources {\n  display: grid;\n  min-width: 0;\n  grid-template-columns: repeat(3, minmax(0, 1fr));\n  gap: 8px;\n}\n\n.audit-demo-resources details {\n  min-width: 0;\n  border: 1px solid var(--t-border);\n  border-radius: var(--t-radius-control);\n  background: var(--t-surface);\n}\n\n.audit-demo-resources summary {\n  display: flex;\n  min-width: 0;\n  min-height: 44px;\n  align-items: center;\n  padding: 8px 10px;\n  color: var(--t-ink);\n  font-size: 11px;\n  font-weight: 720;\n  line-height: 1.4;\n  cursor: pointer;\n  overflow-wrap: anywhere;\n}\n\n.audit-demo-resources summary:focus-visible {\n  outline: 2px solid var(--t-accent);\n  outline-offset: 3px;\n}\n\n.audit-demo-resources p {\n  padding: 0 10px 11px;\n}\n\n.audit-demo-boundary {\n  text-align: center;\n}\n\n@container audit-demo (max-width: 560px) {\n  .audit-demo-resources {\n    grid-template-columns: minmax(0, 1fr);\n  }\n}\n\n@media (max-width: 560px) {\n  .audit-demo-resources {\n    grid-template-columns: minmax(0, 1fr);\n  }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .audit-demo,\n  .audit-demo * {\n    scroll-behavior: auto;\n  }\n}";

const SAMPLE_EVENTS = [
  {
    id: "policy-updated",
    actor: { name: "Ava Patel", detail: "Workspace owner" },
    action: "updated access for",
    resourceKey: "design-review",
    resourceLabel: "Design review",
    category: "access",
    dateTime: "2026-10-14T15:42:00-05:00",
    timeLabel: "3:42 PM",
    description: "Review access changed for the sample workspace.",
    changes: [
      {
        id: "visibility",
        field: "Visibility",
        before: "Private",
        after: "Workspace members",
      },
      {
        id: "commenting",
        field: "Comments",
        before: "Editors",
        after: "All members",
      },
    ],
    recordNote: "Source label: workspace settings",
  },
  {
    id: "brief-renamed",
    actor: { name: "Noah Kim", detail: "Editor" },
    action: "renamed",
    resourceKey: "project-brief",
    resourceLabel: "Project brief",
    category: "content",
    dateTime: "2026-10-14T14:18:00-05:00",
    timeLabel: "2:18 PM",
    description:
      "The supplied record includes the exact previous and next title.",
    changes: [
      {
        id: "title",
        field: "Title",
        before: "Launch outline",
        after: "Project brief",
      },
    ],
    recordNote: "Source label: document settings",
  },
  {
    id: "guest-removed",
    actor: { name: "Mila Santos", detail: "Project lead" },
    action: "removed a guest from",
    resourceKey: "launch-board",
    resourceLabel: "Launch board",
    category: "access",
    dateTime: "2026-10-14T12:06:00-05:00",
    timeLabel: "12:06 PM",
    changes: [
      {
        id: "guest",
        field: "Guest access",
        before: "sample.guest@example.test",
        after: "Removed",
      },
    ],
    recordNote: "Source label: member settings",
  },
  {
    id: "status-changed",
    actor: { name: "Ava Patel", detail: "Workspace owner" },
    action: "changed the status of",
    resourceKey: "launch-board",
    resourceLabel: "Launch board",
    category: "content",
    dateTime: "2026-10-14T10:31:00-05:00",
    timeLabel: "10:31 AM",
    changes: [
      {
        id: "status",
        field: "Status",
        before: "Review",
        after: "Ready",
      },
    ],
    recordNote: "Source label: project board",
  },
] as const;

type ActorFilter = "all" | "ava" | "noah" | "mila";

type CategoryFilter = "all" | "access" | "content";

export function AuditLogDemo() {
  const instanceId = useId().replace(/:/g, "");
  const [actor, setActor] = useState<ActorFilter>("all");
  const [category, setCategory] = useState<CategoryFilter>("all");
  const [exportStatus, setExportStatus] = useState(
    "No sample export has been prepared.",
  );

  const resourceIds = useMemo(
    () =>
      Object.fromEntries(
        ["design-review", "project-brief", "launch-board"].map((key) => [
          key,
          `audit-demo-${instanceId}-${key}`,
        ]),
      ),
    [instanceId],
  );
  const events = useMemo<readonly TidalAuditEvent[]>(
    () =>
      SAMPLE_EVENTS.filter((event) => {
        const actorMatches =
          actor === "all" ||
          event.actor.name.toLocaleLowerCase().startsWith(actor);
        return (
          actorMatches && (category === "all" || event.category === category)
        );
      }).map((event) => ({
        id: event.id,
        actor: event.actor,
        action: event.action,
        resource: {
          label: event.resourceLabel,
          href: `#${resourceIds[event.resourceKey]}`,
        },
        dateTime: event.dateTime,
        timeLabel: event.timeLabel,
        description: "description" in event ? event.description : undefined,
        changes: event.changes,
        recordNote: event.recordNote,
      })),
    [actor, category, resourceIds],
  );

  const filters = useMemo<readonly TidalAuditFilter[]>(
    () => [
      {
        id: "actor",
        label: "Actor",
        value: actor,
        options: [
          { value: "all", label: "All actors", count: 4 },
          { value: "ava", label: "Ava Patel", count: 2 },
          { value: "noah", label: "Noah Kim", count: 1 },
          { value: "mila", label: "Mila Santos", count: 1 },
        ],
        onValueChange: (value: string) => setActor(value as ActorFilter),
      },
      {
        id: "category",
        label: "Record type",
        value: category,
        options: [
          { value: "all", label: "All records", count: 4 },
          { value: "access", label: "Access", count: 2 },
          { value: "content", label: "Content", count: 2 },
        ],
        onValueChange: (value: string) => setCategory(value as CategoryFilter),
      },
    ],
    [actor, category],
  );

  const openResource = (event: MouseEvent<HTMLAnchorElement>) => {
    if (
      event.button !== 0 ||
      event.metaKey ||
      event.ctrlKey ||
      event.shiftKey ||
      event.altKey
    )
      return;
    const href = event.currentTarget.getAttribute("href");
    if (!href?.startsWith("#")) return;
    const target = event.currentTarget.ownerDocument.getElementById(
      href.slice(1),
    );
    if (target instanceof HTMLDetailsElement) target.open = true;
  };

  const linkedEvents: readonly TidalAuditEvent[] = events.map((event) => ({
    ...event,
    resource:
      "href" in event.resource
        ? {
            ...(event.resource as TidalAuditLinkedResource),
            linkProps: { onClick: openResource },
          }
        : event.resource,
  }));

  return (
    <section className="audit-demo" aria-label="Audit log sample">
      <TidalAuditLog
        title="Workspace audit"
        description="Review exact sample changes and their supplied context."
        summary={`${events.length} visible record${events.length === 1 ? "" : "s"}`}
        timezoneLabel="Central time"
        events={linkedEvents}
        filters={filters}
        exportAction={{
          label: "Prepare export preview",
          onExport: () =>
            setExportStatus(
              `Export preview prepared locally for ${events.length} record${events.length === 1 ? "" : "s"}. No file was created.`,
            ),
        }}
        emptyContent="No sample records match both filters."
      />

      <p className="audit-demo-status" role="status">
        {exportStatus}
      </p>

      <div className="audit-demo-resources" aria-label="Sample resource notes">
        <details id={resourceIds["design-review"]}>
          <summary>Design review</summary>
          <p>Sample review space with workspace-member access.</p>
        </details>
        <details id={resourceIds["project-brief"]}>
          <summary>Project brief</summary>
          <p>Sample document using the updated title.</p>
        </details>
        <details id={resourceIds["launch-board"]}>
          <summary>Launch board</summary>
          <p>Sample board with local access and status changes.</p>
        </details>
      </div>

      <p className="audit-demo-boundary">
        Sample records. Filters and export preview stay on this page.
      </p>
    </section>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <AuditLogDemo />
    </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.","Arrow-key behavior follows the exported composite-control implementation."],"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."}

Required title, exact consumer-owned summary, visible timezone label and ordered events. Every event has a unique ID, actor, action, resource, native dateTime/timeLabel and optional description, before-and-after changes, record note, article props/ref and native details props/ref. Resources are static labels or real native anchors with attributes/ref and true/false disabled semantics; disabled anchors omit href and suppress primary/auxiliary handlers. Optional controlled native filters preserve form/name/required attributes/ref, call the native onChange before proposing a value and show unmatched controlled values as unavailable. Optional exportAction is a caller-owned native button callback and never creates a file itself. The labelled record region becomes keyboard focusable only while it overflows. Root/list attributes and refs, heading levels, labels, empty content and footer remain configurable. Duplicate event IDs and unmatched filter values remain visible and produce a linked configuration error. The component never filters, persists, verifies, signs, exports, requests, routes or claims tamper-proof storage.
