# Export dialog

Choose a file format, row scope and fields before requesting an export.

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

## When to use

- Use it when a page needs choose a file format, row scope and fields before requesting an export.
- 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 export dialog.

## 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 Export dialog

```sh
npx shadcn@latest add @tidal-pro/export-dialog
```

Stylesheets: `components/ui/tidal.css`, `components/ui/export-dialog.css`.

## Minimal example

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

## Structured props

- `TidalExportDialog.fields: ReadonlyArray<TidalExportField>`: Required fields value accepted by this exported component.
- `TidalExportDialog.formats: ReadonlyArray<TidalExportFormat>`: Required formats value accepted by this exported component.
- `TidalExportDialog.onOpenChange: (open: boolean) => void`: Callback invoked when the open change interaction is proposed.
- `TidalExportDialog.onValueChange: (next: TidalExportValue, event: TidalExportChangeEvent) => void`: Callback invoked when the value change interaction is proposed.
- `TidalExportDialog.open: boolean`: Required open value accepted by this exported component.
- `TidalExportDialog.scopes: ReadonlyArray<TidalExportScope>`: Required scopes value accepted by this exported component.
- `TidalExportDialog.value: TidalExportValue`: Required value value accepted by this exported component.
- `TidalExportDialog.clearUnavailableProps?: SubmitProps | undefined`: Optional clear unavailable props value accepted by this exported component.
- `TidalExportDialog.clearUnavailableRef?: Ref<HTMLButtonElement> | undefined`: Optional clear unavailable ref value accepted by this exported component.
- `TidalExportDialog.description?: string | undefined` (default "Choose which rows and fields to include."): Optional description value accepted by this exported component.
- `TidalExportDialog.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalExportDialog.error?: ReactNode`: Optional error value accepted by this exported component.
- `TidalExportDialog.footer?: ReactNode`: Optional footer value accepted by this exported component.
- `TidalExportDialog.formatRef?: Ref<HTMLSelectElement> | undefined`: Optional format ref value accepted by this exported component.
- `TidalExportDialog.headerActions?: ReactNode`: Optional header actions value accepted by this exported component.
- `TidalExportDialog.headingLevel?: 2 | 3 | 4 | 5 | 6 | undefined` (default 2): Optional heading level value accepted by this exported component.
- `TidalExportDialog.labels?: Partial<{ format: string; scope: string; fields: string; submit: string; pending: string; empty: string; configuration: string; fieldRequired: string; clearUnavailable: string; }> | undefined`: Optional labels value accepted by this exported component.
- `TidalExportDialog.onExportRequest?: ((value: TidalExportValue, event: FormEvent<HTMLFormElement>) => void) | undefined`: Callback invoked when the export request interaction is proposed.
- `TidalExportDialog.pending?: boolean | undefined` (default false): Optional pending value accepted by this exported component.
- `TidalExportDialog.submitProps?: SubmitProps | undefined`: Optional submit props value accepted by this exported component.
- `TidalExportDialog.submitRef?: Ref<HTMLButtonElement> | undefined`: Optional submit ref value accepted by this exported component.
- `TidalExportDialog.theme?: "light" | "dark" | undefined` (default "light"): Optional theme value accepted by this exported component.
- `TidalExportDialog.title?: string | undefined` (default "Export data"): Optional title value accepted by this exported component.
- `TidalExportDialog.trigger?: ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`: Optional trigger value accepted by this exported component.
- `TidalExportOptions.fields: ReadonlyArray<TidalExportField>`: Required fields value accepted by this exported component.
- `TidalExportOptions.formats: ReadonlyArray<TidalExportFormat>`: Required formats value accepted by this exported component.
- `TidalExportOptions.onValueChange: (next: TidalExportValue, event: TidalExportChangeEvent) => void`: Callback invoked when the value change interaction is proposed.
- `TidalExportOptions.scopes: ReadonlyArray<TidalExportScope>`: Required scopes value accepted by this exported component.
- `TidalExportOptions.value: TidalExportValue`: Required value value accepted by this exported component.
- `TidalExportOptions.clearUnavailableProps?: SubmitProps | undefined`: Optional clear unavailable props value accepted by this exported component.
- `TidalExportOptions.clearUnavailableRef?: Ref<HTMLButtonElement> | undefined`: Optional clear unavailable ref value accepted by this exported component.
- `TidalExportOptions.description?: ReactNode` (default "Choose which rows and fields to include."): Optional description value accepted by this exported component.
- `TidalExportOptions.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalExportOptions.error?: ReactNode`: Optional error value accepted by this exported component.
- `TidalExportOptions.footer?: ReactNode`: Optional footer value accepted by this exported component.
- `TidalExportOptions.formatRef?: Ref<HTMLSelectElement> | undefined`: Optional format ref value accepted by this exported component.
- `TidalExportOptions.headerActions?: ReactNode`: Optional header actions value accepted by this exported component.
- `TidalExportOptions.headingLevel?: 2 | 3 | 4 | 5 | 6 | undefined` (default 2): Optional heading level value accepted by this exported component.
- `TidalExportOptions.labels?: Partial<{ format: string; scope: string; fields: string; submit: string; pending: string; empty: string; configuration: string; fieldRequired: string; clearUnavailable: string; }> | undefined`: Optional labels value accepted by this exported component.
- `TidalExportOptions.onExportRequest?: ((value: TidalExportValue, event: FormEvent<HTMLFormElement>) => void) | undefined`: Callback invoked when the export request interaction is proposed.
- `TidalExportOptions.pending?: boolean | undefined` (default false): Optional pending value accepted by this exported component.
- `TidalExportOptions.submitProps?: SubmitProps | undefined`: Optional submit props value accepted by this exported component.
- `TidalExportOptions.submitRef?: Ref<HTMLButtonElement> | undefined`: Optional submit ref value accepted by this exported component.
- `TidalExportOptions.title?: ReactNode` (default "Export data"): Optional title value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/export-dialog.tsx) | [Manifest](https://tidalui.com/examples/export-dialog.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 { useEffect, useState, type FormEvent } from "react";

import { TidalExportOptions, TidalExportDialog, type TidalExportValue } from "./components/ui/export-dialog";

import { TidalButton } from "./components/ui/tidal-button";

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

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

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



const tidalExampleStyles = ".tidal-scope .export-dialog-demo {\n  width: 100%;\n  max-width: 580px;\n  min-width: 0;\n}\n.tidal-scope .export-dialog-demo > .tidal-export-options {\n  border: 1px solid var(--t-border);\n  border-radius: 18px;\n  background: var(--t-surface);\n  padding: 26px;\n  box-shadow:\n    0 2px 3px #00000003,\n    0 12px 32px #00000005;\n}\n.tidal-scope .export-dialog-note {\n  font-size: 11px;\n  color: var(--t-muted);\n  line-height: 1.6;\n  text-align: center;\n  margin: 14px 8px 0;\n}\n.tidal-scope .export-dialog-open {\n  display: flex;\n  margin: 16px auto 0;\n}\n@media (max-width: 400px) {\n  .tidal-scope .export-dialog-demo > .tidal-export-options {\n    padding: 20px;\n  }\n}";

const formats = [
  { id: "csv", label: "CSV spreadsheet" },
  { id: "json", label: "JSON data" },
];

const scopes = [
  {
    id: "all",
    label: "All contacts",
    detail: "Every row in this sample",
    countLabel: "3 rows",
  },
  {
    id: "filtered",
    label: "Current filter",
    detail: "Contacts with an active project",
    countLabel: "2 rows",
  },
  {
    id: "selected",
    label: "Selected contacts",
    detail: "Only the current selection",
    countLabel: "1 row",
  },
];

const fields = [
  { id: "name", label: "Name" },
  { id: "email", label: "Email address" },
  { id: "company", label: "Company" },
  { id: "role", label: "Role" },
];

const rows = [
  {
    name: "Mira Chen",
    email: "mira@example.com",
    company: "Northstar",
    role: "Admin",
  },
  {
    name: "Jon Bell",
    email: "jon@example.com",
    company: "Field Office",
    role: "Editor",
  },
  {
    name: "Sam Rivera",
    email: "sam@example.com",
    company: "Studio",
    role: "Viewer",
  },
];

export function ExportDialogDemo({
  theme = "light",
}: {
  theme?: "light" | "dark";
}) {
  const [open, setOpen] = useState(false),
    [value, setValue] = useState<TidalExportValue>({
      formatId: "csv",
      scopeId: "all",
      fieldIds: ["name", "email", "company", "role"],
    }),
    [file, setFile] = useState<{
      url: string;
      name: string;
      rows: number;
    } | null>(null);
  useEffect(
    () => () => {
      if (file) URL.revokeObjectURL(file.url);
    },
    [file],
  );
  const update = (next: TidalExportValue) => {
    setValue(next);
    setFile(null);
  };
  const prepare = (
    next: TidalExportValue,
    event: FormEvent<HTMLFormElement>,
  ) => {
    event.preventDefault();
    const chosen = rows
      .slice(
        0,
        next.scopeId === "selected" ? 1 : next.scopeId === "filtered" ? 2 : 3,
      )
      .map((row) =>
        Object.fromEntries(
          next.fieldIds.map((id) => [id, row[id as keyof typeof row]]),
        ),
      );
    const text =
      next.formatId === "json"
        ? JSON.stringify(chosen, null, 2)
        : [
            next.fieldIds,
            ...chosen.map((row) => next.fieldIds.map((id) => row[id])),
          ]
            .map((row) =>
              row
                .map(
                  (cell) =>
                    '"' + String(cell ?? "").replaceAll('"', '""') + '"',
                )
                .join(","),
            )
            .join("\r\n");
    setFile({
      url: URL.createObjectURL(
        new Blob([text], {
          type:
            next.formatId === "json"
              ? "application/json"
              : "text/csv;charset=utf-8",
        }),
      ),
      name: "sample-contacts." + next.formatId,
      rows: chosen.length,
    });
  };
  const options = {
    formats,
    scopes,
    fields,
    value,
    onValueChange: update,
    onExportRequest: prepare,
    footer: file ? (
      <a href={file.url} download={file.name}>
        Download {file.name}
      </a>
    ) : (
      <span>{value.fieldIds.length} fields selected</span>
    ),
  };
  return (
    <div className="export-dialog-demo">
      <TidalExportOptions
        {...options}
        title="Export contacts"
        description="Choose rows and fields for a sample CSV or JSON file."
      />
      <TidalExportDialog
        {...options}
        theme={theme}
        open={open}
        onOpenChange={setOpen}
        title="Export contacts"
        description="Choose rows and fields for a sample CSV or JSON file."
        trigger={
          <TidalButton variant="secondary" className="export-dialog-open">
            Open as dialog
          </TidalButton>
        }
      />
      <p className="export-dialog-note">
        Files contain fictional sample contacts only.
      </p>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <ExportDialogDemo />
    </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.","Escape dismisses the open overlay where the underlying primitive supports dismissal."],"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."}

TidalExportDialog composes the accepted Dialog around TidalExportOptions, which can also render as a native inline form with a forwarded form ref. Consumer supplies uniquely identified formats, scopes and fields, controlled formatId/scopeId/fieldIds, and all data preparation. Native format/radio/checkbox controls propose changes. Submit requires valid available format/scope and at least one field; native form/submitter handlers run first and prevention stops the export callback. Form action/method/target and submitter overrides, submit ref, format ref, field refs, pending/disabled, localized labels, heading level, error and footer are supported. Consumers own authorization, calculations, data selection, file generation, cancellation and delivery. The reusable component performs no request, download, persistence or export operation. The demo explicitly generates a local file containing at most three fictional contacts, then exposes a native download link. Selected missing or disabled field IDs block export until corrected. The localized Clear unavailable field selections action proposes removal of only those IDs, supports native clearUnavailableProps and clearUnavailableRef, respects caller prevention/pending/disabled, and recovers focus to a connected editable field or form if the accepted correction removes its focused button.
