# CSV preview

Inspect parsed rows and field-level validation messages before an import.

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

## When to use

- Use it when a page needs inspect parsed rows and field-level validation messages before an import.
- 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 csv preview.

## 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 CSV preview

```sh
npx shadcn@latest add @tidal-pro/csv-preview
```

Stylesheets: `components/ui/tidal.css`, `components/ui/csv-preview.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/csv-preview.css";
import{TidalCsvPreview}from"./components/ui/csv-preview";
export default()=><div className="tidal-scope"><TidalCsvPreview columns={[{id:"example",label:"Demo"}]} rows={[{id:"example",rowNumber:"value",cells:{}}]}/></div>;
```

## Structured props

- `TidalCsvPreview.columns: ReadonlyArray<TidalCsvColumn>`: Required columns value accepted by this exported component.
- `TidalCsvPreview.rows: ReadonlyArray<TidalCsvRow>`: Required rows value accepted by this exported component.
- `TidalCsvPreview.allButtonProps?: OwnedButtonProps | undefined`: Optional all button props value accepted by this exported component.
- `TidalCsvPreview.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalCsvPreview.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalCsvPreview.exportButtonProps?: OwnedButtonProps | undefined`: Optional export button props value accepted by this exported component.
- `TidalCsvPreview.exportButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional export button ref value accepted by this exported component.
- `TidalCsvPreview.fileName?: ReactNode`: Optional file name value accepted by this exported component.
- `TidalCsvPreview.headingLevel?: 2 | 3 | 4 | 5 | 6 | undefined` (default 2): Optional heading level value accepted by this exported component.
- `TidalCsvPreview.issuesButtonProps?: OwnedButtonProps | undefined`: Optional issues button props value accepted by this exported component.
- `TidalCsvPreview.labels?: Partial<{ all: string; issues: string; export: string; exporting: string; row: string; empty: string; noIssues: string; missing: string; valid: string; errors: string; warnings: string; invalid: string; unavailableTotal: string; table: string; validation: string; }> | undefined`: Optional labels value accepted by this exported component.
- `TidalCsvPreview.onExportIssues?: ((rows: readonly TidalCsvRow[], event: MouseEvent<HTMLButtonElement>) => void) | undefined`: Callback invoked when the export issues interaction is proposed.
- `TidalCsvPreview.onViewChange?: ((view: TidalCsvView, event: MouseEvent<HTMLButtonElement>) => void) | undefined`: Callback invoked when the view change interaction is proposed.
- `TidalCsvPreview.pending?: boolean | undefined` (default false): Optional pending value accepted by this exported component.
- `TidalCsvPreview.summary?: ((shown: number, supplied: number, total: number | undefined) => ReactNode) | undefined`: Optional summary value accepted by this exported component.
- `TidalCsvPreview.title?: ReactNode` (default "Data preview"): Optional title value accepted by this exported component.
- `TidalCsvPreview.totalRows?: number | undefined`: Optional total rows value accepted by this exported component.
- `TidalCsvPreview.view?: TidalCsvView | undefined` (default "all"): Optional view value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/csv-preview.tsx) | [Manifest](https://tidalui.com/examples/csv-preview.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 { useState } from "react";

import { TidalCsvPreview, type TidalCsvView, type TidalCsvRow } from "./components/ui/csv-preview";

import "./components/ui/csv-preview.css";



const tidalExampleStyles = ".tidal-scope .csv-preview-demo {\n  width: 100%;\n  max-width: 1080px;\n  min-width: 0;\n}\n.tidal-scope .csv-preview-note {\n  font-size: 11px;\n  line-height: 1.6;\n  color: var(--t-muted);\n  text-align: center;\n  margin: 14px 8px 0;\n}";

const rows: readonly TidalCsvRow[] = [
  {
    id: "1",
    rowNumber: 2,
    cells: { name: "Mira Chen", email: "mira@example.com", role: "Admin" },
  },
  {
    id: "2",
    rowNumber: 3,
    cells: { name: "Jon Bell", email: "jon.example.com", role: "Editor" },
    issues: [
      {
        id: "email",
        columnId: "email",
        severity: "error",
        message: "Enter a complete email address.",
      },
    ],
  },
  {
    id: "3",
    rowNumber: 4,
    cells: { name: "Sam Rivera", email: "sam@example.com", role: "Member" },
    issues: [
      {
        id: "role",
        columnId: "role",
        severity: "warning",
        message: "Member will use the default Viewer role.",
      },
    ],
  },
];

export function CsvPreviewDemo() {
  const [view, setView] = useState<TidalCsvView>("all");
  return (
    <div className="csv-preview-demo">
      <TidalCsvPreview
        title="Review imported contacts"
        fileName="contacts.csv"
        columns={[
          { id: "name", label: "Name", typeLabel: "Text" },
          { id: "email", label: "Email", typeLabel: "Email address" },
          { id: "role", label: "Role", typeLabel: "Workspace role" },
        ]}
        rows={rows}
        totalRows={3}
        view={view}
        onViewChange={setView}
        summary={(shown, _supplied, total) => (
          <>
            {shown} of {total} data rows · 1 error, 1 warning
          </>
        )}
      />
      <p className="csv-preview-note">
        Sample parsed data. Filter the rows to inspect validation messages.
      </p>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <CsvPreviewDemo />
    </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 columns with unique IDs, parsed row objects with unique IDs, exact row-number labels and cells, and optional per-row warning/error messages with unique IDs and optional column references. The optional controlled all/issues view filters supplied rows. totalRows must be an exact safe integer at least as large as the supplied sample; absence is disclosed. Phone row cards replace the native desktop table without hiding individual values. Empty/configuration states, localized labels/count summary, title/file/description, section props/ref, heading level, native filter/export button props and export ref are supported. Native handlers run first; prevention stops proposals. Disabled or pending controls remain inert. An optional export callback receives the supplied issue rows only. No parser, download, file read, upload, import, validation inference or network/storage behavior is bundled.
