# Column mapper

Match source columns to destination fields with sample values and duplicate protection.

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

## When to use

- Use it when a page needs match source columns to destination fields with sample values and duplicate protection.
- 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 column mapper.

## 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 Column mapper

```sh
npx shadcn@latest add @tidal-pro/column-mapper
```

Stylesheets: `components/ui/tidal.css`, `components/ui/column-mapper.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/column-mapper.css";
import{TidalColumnMapper}from"./components/ui/column-mapper";
export default()=><div className="tidal-scope"><TidalColumnMapper fields={[{id:"example",label:"Demo"}]} onValueChange={() => {}} sources={[{id:"example",label:"Demo"}]} value={{}}/></div>;
```

## Structured props

- `TidalColumnMapper.fields: ReadonlyArray<TidalColumnField>`: Required fields value accepted by this exported component.
- `TidalColumnMapper.onValueChange: (next: Record<string, string | undefined>, fieldId: string, event: ChangeEvent<HTMLSelectElement>) => void`: Callback invoked when the value change interaction is proposed.
- `TidalColumnMapper.sources: ReadonlyArray<TidalColumnSource>`: Required sources value accepted by this exported component.
- `TidalColumnMapper.value: Readonly<Record<string, string | undefined>>`: Required value value accepted by this exported component.
- `TidalColumnMapper.allowDuplicateSources?: boolean | undefined` (default false): Optional allow duplicate sources value accepted by this exported component.
- `TidalColumnMapper.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalColumnMapper.emptySample?: ReactNode` (default "No column selected"): Optional empty sample value accepted by this exported component.
- `TidalColumnMapper.errors?: Readonly<Record<string, ReactNode>> | undefined`: Optional errors value accepted by this exported component.
- `TidalColumnMapper.headerActions?: ReactNode`: Optional header actions value accepted by this exported component.
- `TidalColumnMapper.headingLevel?: 2 | 3 | 4 | 5 | 6 | undefined` (default 3): Optional heading level value accepted by this exported component.
- `TidalColumnMapper.missingSample?: ReactNode` (default "No sample provided"): Optional missing sample value accepted by this exported component.
- `TidalColumnMapper.placeholder?: string | undefined` (default "Choose a column"): Optional placeholder value accepted by this exported component.
- `TidalColumnMapper.readOnly?: boolean | undefined` (default false): Optional read only value accepted by this exported component.
- `TidalColumnMapper.sampleLabel?: string | undefined` (default "Sample value"): Optional sample label value accepted by this exported component.
- `TidalColumnMapper.showValidation?: boolean | undefined` (default false): Optional show validation value accepted by this exported component.
- `TidalColumnMapper.summary?: ((mapped: number, total: number) => ReactNode) | undefined`: Optional summary value accepted by this exported component.
- `TidalColumnMapper.title?: ReactNode` (default "Map columns"): Optional title value accepted by this exported component.
- `TidalColumnMapper.unavailableColumnLabel?: string | undefined` (default "Unavailable column"): Optional unavailable column label value accepted by this exported component.

## Complete usage example

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

import { TidalColumnMapper, type TidalColumnMapping } from "./components/ui/column-mapper";

import "./components/ui/column-mapper.css";

import "./components/ui/native-select.css";



const tidalExampleStyles = ".tidal-scope .column-mapper-demo {\n  width: min(100%, 760px);\n  min-width: 0;\n}\n.tidal-scope .column-mapper-demo .tidal-column-header-actions button {\n  min-height: 44px;\n  min-width: 44px;\n  padding: 9px 13px;\n  border: 1px solid var(--t-border);\n  border-radius: var(--t-radius-control);\n  background: var(--t-surface);\n  color: var(--t-ink);\n  font: inherit;\n  font-size: 12px;\n  cursor: pointer;\n}\n.tidal-scope .column-mapper-demo > p {\n  margin: 14px 2px 0;\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.6;\n  overflow-wrap: anywhere;\n}";

const sources = [
  { id: "full_name", label: "full_name", sample: "Avery Morgan" },
  { id: "email_address", label: "email_address", sample: "avery@example.test" },
  { id: "company", label: "company", sample: "Northstar" },
  { id: "role", label: "role", sample: "Product designer" },
];

const fields = [
  { id: "name", label: "Name", required: true },
  { id: "email", label: "Email address", required: true },
  { id: "organization", label: "Company" },
];

export function ColumnMapperDemo() {
  const [value, setValue] = useState<TidalColumnMapping>({
    name: "full_name",
    email: "email_address",
  });
  const [status, setStatus] = useState(
    "Preview a CSV mapping. No file is imported.",
  );
  return (
    <div className="column-mapper-demo">
      <TidalColumnMapper
        sources={sources}
        fields={fields}
        value={value}
        onValueChange={(next, field) => {
          setValue(next);
          setStatus(`Mapping for ${field} updated locally.`);
        }}
        headerActions={
          <button
            type="button"
            onClick={() => {
              setValue({});
              setStatus("All mappings cleared locally.");
            }}
          >
            Clear mapping
          </button>
        }
      />
      <p role="status">{status}</p>
    </div>
  );
}

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

```

## Gotchas

- Install the declared registry dependencies and render inside a tidal-scope with the foundation stylesheet loaded.

## 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."}

sources and fields require unique nonempty IDs. Controlled value maps destination IDs to source IDs; onValueChange proposes a fresh record, field ID and native event without importing or reading a file. Unmapping deletes that field key while preserving unrelated mapping keys. Each field has a label, optional description/required/disabled state, native select props and ref. Native onChange runs first and prevention cancels the proposal. Duplicate source use is prevented by default; allowDuplicateSources opts in. Unknown selected sources and duplicate controlled values receive visible linked errors. Required empty errors appear with showValidation; native required validation always applies. Optional title, headerActions, errors, disabled/readOnly, placeholder/sample labels, empty/missing samples, unavailableColumnLabel, summary formatter, headingLevel and native root attributes/ref. The component composes TidalNativeSelect and retains native form semantics. No file read, import, request, storage or data mutation occurs.
