# Dialog

A modal with a title, form and focus management.

Access: pro. Category: Feedback. Kind: primitive.

## When to use

- Use it when a product interface needs a modal with a title, form and focus management.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose sheet-drawer instead when use the drawer for supporting work that benefits from staying beside the current page.

## 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 Dialog

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

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

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/dialog.css";
import{TidalDialog}from"./components/ui/dialog";
export default()=><div className="tidal-scope"><TidalDialog children={"value"} description={"Demo"} onOpenChange={() => {}} open={false} title={"Demo"}/></div>;
```

## Structured props

- `TidalDialog.children: ReactNode`: Required children value accepted by this exported component.
- `TidalDialog.description: string`: Required description value accepted by this exported component.
- `TidalDialog.onOpenChange: (open: boolean) => void`: Callback invoked when the open change interaction is proposed.
- `TidalDialog.open: boolean`: Required open value accepted by this exported component.
- `TidalDialog.title: string`: Required title value accepted by this exported component.
- `TidalDialog.className?: string | undefined` (default ""): Optional class name value accepted by this exported component.
- `TidalDialog.footer?: ReactNode`: Optional footer value accepted by this exported component.
- `TidalDialog.theme?: "light" | "dark" | undefined` (default "light"): Optional theme value accepted by this exported component.
- `TidalDialog.trigger?: ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`: Optional trigger value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/dialog.tsx) | [Manifest](https://tidalui.com/examples/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
import "./components/ui/tidal.css";

import { useState, useRef, useId } from "react";

import { Plus } from "lucide-react";

import { TidalDialog } from "./components/ui/dialog";

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

import { TidalField } from "./components/ui/form-field";

import "./components/ui/form-field.css";

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



const tidalExampleStyles = ".dialog-specimen{width:100%;max-width:330px;text-align:center;color:var(--t-ink)}.dialog-specimen>.demo-eyebrow{display:block;margin:20px 0 12px;font-size:11px}.dialog-specimen>h3{font-size:23px;letter-spacing:-.9px}.dialog-specimen>p{font-size:11px;color:var(--t-muted);margin:9px 0 22px}.dialog-specimen>.dialog-demo-status{font-size:11px;margin-top:19px;margin-bottom:0}.workspace-illustration{height:73px;width:88px;position:relative;margin:auto}.workspace-illustration>span{position:absolute;width:66px;height:48px;border:1px solid var(--t-border);border-radius:9px;background:var(--t-surface);box-shadow:0 7px 15px #1f1f1f08;top:22px;left:20px;transform:rotate(8deg)}.workspace-illustration>span:nth-child(2){top:11px;left:10px;transform:rotate(-5deg);background:var(--t-wash)}.workspace-illustration>span:nth-child(3){top:0;left:0;transform:rotate(-12deg);background:var(--t-surface)}.workspace-illustration>span:before{content:\"\";position:absolute;inset:12px 12px auto;height:4px;background:var(--t-border);border-radius:2px;box-shadow:0 9px var(--t-border)}\n\n.workspace-illustration>span{transition:transform 420ms var(--t-ease-out),box-shadow 420ms var(--t-ease-out)}\n.dialog-specimen:hover .workspace-illustration>span:first-child,.dialog-specimen:focus-within .workspace-illustration>span:first-child{transform:translate(4px,3px) rotate(14deg)}\n.dialog-specimen:hover .workspace-illustration>span:nth-child(3),.dialog-specimen:focus-within .workspace-illustration>span:nth-child(3){transform:translate(-4px,-3px) rotate(-16deg)}\n@media(prefers-reduced-motion:reduce){.dialog-specimen:hover .workspace-illustration>span:first-child,.dialog-specimen:focus-within .workspace-illustration>span:first-child{transform:rotate(8deg)}.dialog-specimen:hover .workspace-illustration>span:nth-child(3),.dialog-specimen:focus-within .workspace-illustration>span:nth-child(3){transform:rotate(-12deg)}}";

export function DialogDemo({ theme = "light" }: { theme?: "light" | "dark" }) {
  const [open, setOpen] = useState(false);
  const [name, setName] = useState("");
  const [error, setError] = useState("");
  const [created, setCreated] = useState("");
  const field = useRef<HTMLInputElement>(null);
  const formId = useId();
  return (
    <div className="dialog-specimen">
      <div className="workspace-illustration" aria-hidden="true">
        <span />
        <span />
        <span />
      </div>

      <TidalDialog
        theme={theme}
        open={open}
        onOpenChange={(value) => {
          setOpen(value);
          if (!value) setError("");
        }}
        title="Create workspace"
        description="Enter a name for this sample workspace."
        trigger={
          <TidalButton>
            <Plus size={15} aria-hidden="true" />
            Create workspace
          </TidalButton>
        }
        footer={
          <>
            <TidalButton variant="secondary" onClick={() => setOpen(false)}>
              Cancel
            </TidalButton>
            <TidalButton type="submit" form={formId}>
              Create workspace
            </TidalButton>
          </>
        }
      >
        <form
          id={formId}
          noValidate
          onSubmit={(e) => {
            e.preventDefault();
            if (!name.trim()) {
              setError("Give your workspace a name.");
              field.current?.focus({ preventScroll: true });
              return;
            }
            setCreated(name.trim());
            setOpen(false);
            setError("");
            setName("");
          }}
        >
          <TidalField
            ref={field}
            label="Workspace name"
            required
            value={name}
            onChange={(e) => {
              setName(e.target.value);
              setError("");
            }}
            placeholder="e.g. Northstar Studio"
            error={error}
          />
        </form>
      </TidalDialog>
      <p className="dialog-demo-status" role="status">
        {created
          ? created + " created. Sample workspace only."
          : "Create a sample workspace."}
      </p>
    </div>
  );
}

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

Controlled open, onOpenChange, title, description and children required. Optional single focusable trigger element, footer, theme and className (content). Radix traps focus, closes on Escape and returns focus to trigger. Pass theme for portal palette. Consumer owns form/action behavior.
