# Import wizard

Prepare a file mapping, review parsed rows, and emit an import plan without executing an import.

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

## When to use

- Use it when a page needs prepare a file mapping, review parsed rows, and emit an import plan without executing an import.
- 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 import wizard.

## 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 Import wizard

```sh
npx shadcn@latest add @tidal-pro/import-wizard
```

Stylesheets: `components/ui/tidal.css`, `components/ui/import-wizard.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/import-wizard.css";
import{TidalImportWizard}from"./components/ui/import-wizard";
export default(p:Parameters<typeof TidalImportWizard>[0])=><div className="tidal-scope"><TidalImportWizard {...p}/></div>;
```

## Structured props

- `TidalImportWizard.fields: ReadonlyArray<TidalColumnField>`: Required fields value accepted by this exported component.
- `TidalImportWizard.fileAdapter: ReactNode`: Required file adapter value accepted by this exported component.
- `TidalImportWizard.mapping: Readonly<Record<string, string | undefined>>`: Required mapping value accepted by this exported component.
- `TidalImportWizard.onMappingChange: (next: Record<string, string | undefined>, fieldId: string, event: React.ChangeEvent<HTMLSelectElement>) => void`: Callback invoked when the mapping change interaction is proposed.
- `TidalImportWizard.onStepChange: (next: TidalImportStep, event: React.MouseEvent<HTMLButtonElement>) => void`: Callback invoked when the step change interaction is proposed.
- `TidalImportWizard.preview: TidalImportPreview`: Required preview value accepted by this exported component.
- `TidalImportWizard.sources: ReadonlyArray<TidalColumnSource>`: Required sources value accepted by this exported component.
- `TidalImportWizard.step: TidalImportStep`: Required step value accepted by this exported component.
- `TidalImportWizard.title: ReactNode`: Required title value accepted by this exported component.
- `TidalImportWizard.cancelButtonProps?: NativeButtonProps | undefined`: Optional cancel button props value accepted by this exported component.
- `TidalImportWizard.cancelButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional cancel button ref value accepted by this exported component.
- `TidalImportWizard.cancelStep?: TidalImportStep | undefined` (default "review"): Optional cancel step value accepted by this exported component.
- `TidalImportWizard.canContinue?: boolean | undefined` (default true): Optional can continue value accepted by this exported component.
- `TidalImportWizard.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalImportWizard.downloadButtonProps?: NativeButtonProps | undefined`: Optional download button props value accepted by this exported component.
- `TidalImportWizard.downloadButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional download button ref value accepted by this exported component.
- `TidalImportWizard.file?: TidalImportFileSummary | undefined`: Optional file value accepted by this exported component.
- `TidalImportWizard.fileError?: ReactNode`: Optional file error value accepted by this exported component.
- `TidalImportWizard.formProps?: (Omit<Omit<DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref">, "aria-disabled" | "children" | "dangerouslySetInnerHTML" | "onSubmit"> & { onSubmit?: (event: FormEvent<HTMLFormElement>) => void; }) | undefined`: Optional form props value accepted by this exported component.
- `TidalImportWizard.formRef?: Ref<HTMLFormElement> | undefined`: Optional form ref value accepted by this exported component.
- `TidalImportWizard.headingLevel?: 2 | 3 | 4 | 5 | 6 | undefined` (default 2): Optional heading level value accepted by this exported component.
- `TidalImportWizard.labels?: Partial<{ file: string; mapping: string; review: string; progress: string; result: string; previous: string; next: string; prepare: string; cancel: string; downloadErrors: string; rowIssue: string; noColumns: string; validFileRequired: string; selectedFile: string; noFile: string; }> | undefined` (default {}): Optional labels value accepted by this exported component.
- `TidalImportWizard.mappingErrors?: Readonly<Record<string, ReactNode>> | undefined`: Optional mapping errors value accepted by this exported component.
- `TidalImportWizard.nextButtonProps?: NativeButtonProps | undefined`: Optional next button props value accepted by this exported component.
- `TidalImportWizard.nextButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional next button ref value accepted by this exported component.
- `TidalImportWizard.onCancelProgress?: ((event: React.MouseEvent<HTMLButtonElement>) => void) | undefined`: Callback invoked when the cancel progress interaction is proposed.
- `TidalImportWizard.onDownloadErrorRows?: ((event: React.MouseEvent<HTMLButtonElement>) => void) | undefined`: Callback invoked when the download error rows interaction is proposed.
- `TidalImportWizard.onImportPlan?: ((plan: TidalImportPlan, event: FormEvent<HTMLFormElement>) => void) | undefined`: Callback invoked when the import plan interaction is proposed.
- `TidalImportWizard.persistentFields?: ReadonlyArray<{ name: string; value: string; }> | undefined` (default []): Optional persistent fields value accepted by this exported component.
- `TidalImportWizard.planStep?: TidalImportStep | undefined` (default "progress"): Optional plan step value accepted by this exported component.
- `TidalImportWizard.previousButtonProps?: NativeButtonProps | undefined`: Optional previous button props value accepted by this exported component.
- `TidalImportWizard.previousButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional previous button ref value accepted by this exported component.
- `TidalImportWizard.progress?: TidalImportProgress | undefined`: Optional progress value accepted by this exported component.
- `TidalImportWizard.result?: ReactNode`: Optional result value accepted by this exported component.
- `TidalImportWizard.submitButtonProps?: NativeButtonProps | undefined`: Optional submit button props value accepted by this exported component.
- `TidalImportWizard.submitButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional submit button ref value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/import-wizard.tsx) | [Manifest](https://tidalui.com/examples/import-wizard.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, useLayoutEffect, useMemo, useRef, useState } from "react";

import { TidalImportWizard, type TidalImportFileSummary, type TidalImportStep } from "./components/ui/import-wizard";

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

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

import "./components/ui/import-wizard.css";

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



const tidalExampleStyles = ".tidal-scope .import-wizard-demo {\n  display: grid;\n  width: min(100%, 900px);\n  min-width: 0;\n  gap: 14px;\n}\n\n.tidal-scope .import-wizard-adapter {\n  display: flex;\n  min-width: 0;\n  align-items: center;\n  justify-content: center;\n  gap: 10px;\n}\n\n.tidal-scope .import-wizard-adapter input {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  overflow: hidden;\n  clip-path: inset(50%);\n}\n\n.tidal-scope .import-wizard-adapter > span {\n  color: var(--t-muted);\n  font-size: 11px;\n}\n\n.tidal-scope .import-wizard-result {\n  display: grid;\n  justify-items: start;\n  gap: 10px;\n  padding: 22px;\n  border: 1px solid var(--t-line);\n  border-radius: 16px;\n  background: var(--t-subtle);\n}\n\n.tidal-scope .import-wizard-result strong {\n  font-size: 18px;\n  line-height: 1.2;\n}\n\n.tidal-scope .import-wizard-result p,\n.tidal-scope .import-wizard-status {\n  margin: 0;\n  color: var(--t-muted);\n  font-size: 12px;\n  line-height: 1.55;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .import-wizard-result button {\n  min-width: 44px;\n  min-height: 44px;\n  padding: 10px 15px;\n  border: 1px solid var(--t-ink);\n  border-radius: 10px;\n  background: var(--t-ink);\n  color: var(--t-surface);\n  font: inherit;\n  font-size: 12px;\n  font-weight: 700;\n  cursor: pointer;\n}\n\n.tidal-scope .import-wizard-result button:focus-visible {\n  outline: 2px solid var(--t-ink);\n  outline-offset: 3px;\n}\n\n.tidal-scope .import-wizard-status {\n  padding-inline: 4px;\n}\n\n@container tidal-import (max-width: 440px) {\n  .tidal-scope .import-wizard-adapter {\n    align-items: stretch;\n    flex-direction: column;\n  }\n\n  .tidal-scope .import-wizard-adapter > span {\n    text-align: center;\n  }\n}";

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

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

const preview = {
  columns: [
    { id: "name", label: "Name" },
    { id: "email", label: "Email address" },
    { id: "organization", label: "Company" },
  ],
  rows: [
    {
      id: "row-1",
      cells: {
        name: "Avery Morgan",
        email: "avery@example.test",
        organization: "Northstar",
      },
    },
    {
      id: "row-2",
      cells: {
        name: "Noah Chen",
        email: "noah@example.test",
        organization: "Field Office",
      },
    },
    {
      id: "row-3",
      cells: {
        name: "Mila Ortiz",
        email: "missing address",
        organization: "Studio",
      },
      issue: "Email needs review",
    },
  ],
  totalRows: 3,
};

const sampleFile: TidalImportFileSummary = {
  id: "sample-contacts-csv",
  name: "sample-contacts.csv",
  size: "1.4 KB",
  type: "CSV sample",
  rowCount: 3,
  status: "valid",
  statusLabel: "Ready for mapping",
};

export function ImportWizardDemo() {
  const nativeId = useId().replace(/:/g, "");
  const [step, setStep] = useState<TidalImportStep>("file");
  const [file, setFile] = useState<TidalImportFileSummary | undefined>();
  const [fileError, setFileError] = useState<string>();
  const [mapping, setMapping] = useState<TidalColumnMapping>({
    name: "full_name",
    email: "email",
    organization: "company",
  });
  const [status, setStatus] = useState(
    "Choose the fictional sample to prepare an import plan locally.",
  );
  const nativeInputRef = useRef<HTMLInputElement>(null);
  const sampleButtonRef = useRef<HTMLButtonElement>(null);
  const resetButtonRef = useRef<HTMLButtonElement>(null);
  const focusIntent = useRef<{
    expected: TidalImportStep;
    origin: HTMLButtonElement;
  } | null>(null);
  const requiredReady = useMemo(
    () => Boolean(mapping.name && mapping.email),
    [mapping],
  );

  const reset = () => {
    setStep("file");
    setFile(undefined);
    setFileError(undefined);
    setMapping({ name: "full_name", email: "email", organization: "company" });
    if (nativeInputRef.current) nativeInputRef.current.value = "";
    setStatus("Sample reset locally.");
  };

  useLayoutEffect(() => {
    const intent = focusIntent.current;
    if (!intent || intent.expected !== step) return;
    const active = intent.origin.ownerDocument.activeElement;
    if (
      active === intent.origin ||
      active === intent.origin.ownerDocument.body ||
      !(active instanceof HTMLElement) ||
      !active.isConnected
    ) {
      (step === "result"
        ? resetButtonRef.current
        : sampleButtonRef.current
      )?.focus({ preventScroll: true });
    }
    focusIntent.current = null;
  }, [step]);

  return (
    <div className="import-wizard-demo">
      <TidalImportWizard
        title="Import contacts"
        description="Prepare a file mapping and row review before handing the plan to your application."
        step={step}
        onStepChange={(next) => {
          setStep(next);
          setStatus(`${next[0].toUpperCase()}${next.slice(1)} step opened.`);
        }}
        file={file}
        fileError={fileError}
        fileAdapter={
          <div className="import-wizard-adapter">
            <input
              ref={nativeInputRef}
              id={`${nativeId}-file`}
              type="file"
              accept=".csv,text/csv"
              onChange={(event) => {
                const selected = event.currentTarget.files?.[0];
                if (!selected) return;
                setFile({
                  id: `local-${selected.name}`,
                  name: selected.name,
                  size: `${Math.max(1, Math.ceil(selected.size / 1024))} KB`,
                  type: selected.type || "Unknown file type",
                  status: "invalid",
                  statusLabel: "Not parsed by this demo",
                });
                setFileError(
                  "This preview does not read files. Use the fictional sample to continue.",
                );
                setStatus(
                  "Only local file metadata was read by the native input.",
                );
              }}
            />
            <label htmlFor={`${nativeId}-file`}>Choose CSV</label>
            <span>or</span>
            <button
              ref={sampleButtonRef}
              type="button"
              onClick={() => {
                setFile(sampleFile);
                setFileError(undefined);
                setStatus("Fictional sample ready for mapping.");
              }}
            >
              Use sample CSV
            </button>
          </div>
        }
        sources={sources}
        fields={fields}
        mapping={mapping}
        onMappingChange={(next) => {
          setMapping(next);
          setStatus("Mapping updated locally.");
        }}
        preview={preview}
        canContinue={
          step === "file"
            ? file?.id === sampleFile.id
            : step === "mapping"
              ? requiredReady
              : true
        }
        formProps={{
          action: "#prepared-import-plan",
          method: "get",
        }}
        submitButtonProps={{
          name: "intent",
          value: "prepare-import-plan",
          formAction: "#sample-import-plan",
        }}
        onImportPlan={(_plan, event) => {
          event.preventDefault();
          setStep("progress");
          setStatus("Import plan prepared locally. No rows were imported.");
        }}
        onDownloadErrorRows={(event) => {
          event.preventDefault();
          setStatus(
            "Error-row download requested locally. No file was generated.",
          );
        }}
        onCancelProgress={() => {
          setStep("review");
          setStatus("Sample preparation cancelled locally.");
        }}
        progress={{
          value: 3,
          max: 4,
          label: "Preparing sample plan",
          valueLabel: "3 of 4 checks",
          description: "Local preview state only.",
          actions: (
            <button
              type="button"
              onClick={(event) => {
                focusIntent.current = {
                  expected: "result",
                  origin: event.currentTarget,
                };
                setStep("result");
                setStatus("Sample plan is ready for consumer handling.");
              }}
            >
              Complete sample
            </button>
          ),
        }}
        result={
          <div className="import-wizard-result">
            <strong>Import plan ready</strong>
            <p>
              Three fictional rows and the selected mapping are ready for the
              consumer callback. Nothing was uploaded or imported.
            </p>
            <button
              ref={resetButtonRef}
              type="button"
              onClick={(event) => {
                focusIntent.current = {
                  expected: "file",
                  origin: event.currentTarget,
                };
                reset();
              }}
            >
              Reset sample
            </button>
          </div>
        }
      />
      <p className="import-wizard-status" role="status">
        {status}
      </p>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <ImportWizardDemo />
    </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."}

Controlled step supports file, mapping, review, progress and result stages. The consumer supplies the file adapter, file metadata and validation state; source/destination schemas and controlled mapping; parsed preview columns/rows/issues; progress/result content; and every operation callback. onImportPlan receives only the file ID, mapping and native form event, and can run only from Review with a valid supplied file. A missing or invalid file leaves the submitter focusable, unavailable and linked to a visible localized reason. The wizard never reads, parses, uploads or imports a file. Native form action/method, submitter overrides, refs, caller-first prevention, persistent hidden fields, error-row download request and progress cancel request are preserved. Accepted Previous/Continue navigation prevents its original click default, uses a distinct submitter identity, and focuses the new panel without stealing focus after declined or unrelated changes. Native section attributes/ref, bounded heading level, labels, nullish/numeric content and controlled availability are supported. Nonnegative safe counts render; malformed counts are omitted or replaced by the visible row count. The review uses a semantic table with an owner-window observed overflow-only keyboard region and an explicit no-column state. Consumers own parsing, validation, authorization, transport, storage, progress and results.
