# Contact form

A premium native contact and sales form with truthful consumer-owned status states.

Access: pro. Category: Forms. Kind: composite.

## When to use

- Use it when a page needs a premium native contact and sales form with truthful consumer-owned status states.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose form-field instead when a labeled email field with validation and help text is the actual interface need, rather than contact form.

## 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 Contact form

```sh
npx shadcn@latest add @tidal-pro/contact-form
```

Stylesheets: `components/ui/tidal.css`, `components/ui/contact-form.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/contact-form.css";
import{TidalContactForm}from"./components/ui/contact-form";
export default()=><div className="tidal-scope"><TidalContactForm title={"Demo"}/></div>;
```

## Structured props

- `TidalContactForm.title: string`: Required title value accepted by this exported component.
- `TidalContactForm.companyError?: string | undefined`: Optional company error value accepted by this exported component.
- `TidalContactForm.companyInputProps?: ContactInputProps | undefined`: Optional company input props value accepted by this exported component.
- `TidalContactForm.companyLabel?: string | undefined` (default "Company"): Optional company label value accepted by this exported component.
- `TidalContactForm.companyRef?: Ref<HTMLInputElement> | undefined`: Optional company ref value accepted by this exported component.
- `TidalContactForm.defaultIntent?: string | undefined`: Optional default intent value accepted by this exported component.
- `TidalContactForm.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalContactForm.emailError?: string | undefined`: Optional email error value accepted by this exported component.
- `TidalContactForm.emailInputProps?: ContactInputProps | undefined`: Optional email input props value accepted by this exported component.
- `TidalContactForm.emailLabel?: string | undefined` (default "Work email"): Optional email label value accepted by this exported component.
- `TidalContactForm.emailRef?: Ref<HTMLInputElement> | undefined`: Optional email ref value accepted by this exported component.
- `TidalContactForm.eyebrow?: ReactNode` (default "Start a conversation"): Optional eyebrow value accepted by this exported component.
- `TidalContactForm.footer?: ReactNode`: Optional footer value accepted by this exported component.
- `TidalContactForm.formError?: string | undefined`: Optional form error value accepted by this exported component.
- `TidalContactForm.formErrorRef?: Ref<HTMLDivElement> | undefined`: Optional form error ref value accepted by this exported component.
- `TidalContactForm.headingLevel?: "h2" | "h3" | "h4" | undefined` (default "h2"): Optional heading level value accepted by this exported component.
- `TidalContactForm.intent?: string | undefined`: Optional intent value accepted by this exported component.
- `TidalContactForm.intentLabel?: string | undefined` (default "What would you like to discuss?"): Optional intent label value accepted by this exported component.
- `TidalContactForm.intentOptions?: ReadonlyArray<TidalContactIntentOption> | undefined` (default []): Optional intent options value accepted by this exported component.
- `TidalContactForm.intentRef?: Ref<HTMLSelectElement> | undefined`: Optional intent ref value accepted by this exported component.
- `TidalContactForm.intentSelectProps?: ContactSelectProps | undefined`: Optional intent select props value accepted by this exported component.
- `TidalContactForm.messageError?: string | undefined`: Optional message error value accepted by this exported component.
- `TidalContactForm.messageInputProps?: ContactTextareaProps | undefined`: Optional message input props value accepted by this exported component.
- `TidalContactForm.messageLabel?: string | undefined` (default "How can we help?"): Optional message label value accepted by this exported component.
- `TidalContactForm.messageRef?: Ref<HTMLTextAreaElement> | undefined`: Optional message ref value accepted by this exported component.
- `TidalContactForm.nameError?: string | undefined`: Optional name error value accepted by this exported component.
- `TidalContactForm.nameInputProps?: ContactInputProps | undefined`: Optional name input props value accepted by this exported component.
- `TidalContactForm.nameLabel?: string | undefined` (default "Name"): Optional name label value accepted by this exported component.
- `TidalContactForm.nameRef?: Ref<HTMLInputElement> | undefined`: Optional name ref value accepted by this exported component.
- `TidalContactForm.onIntentChange?: ((intent: TidalContactIntentOption) => void) | undefined`: Callback invoked when the intent change interaction is proposed.
- `TidalContactForm.onStatusAction?: ((status: Exclude<TidalContactFormStatus, "idle">) => void) | undefined`: Callback invoked when the status action interaction is proposed.
- `TidalContactForm.pending?: boolean | undefined` (default false): Optional pending value accepted by this exported component.
- `TidalContactForm.pendingLabel?: string | undefined` (default "Preparing"): Optional pending label value accepted by this exported component.
- `TidalContactForm.status?: TidalContactFormStatus | undefined` (default "idle"): Optional status value accepted by this exported component.
- `TidalContactForm.statusActionLabel?: string | undefined`: Optional status action label value accepted by this exported component.
- `TidalContactForm.statusMessage?: string | undefined`: Optional status message value accepted by this exported component.
- `TidalContactForm.statusRef?: Ref<HTMLDivElement> | undefined`: Optional status ref value accepted by this exported component.
- `TidalContactForm.submitButtonProps?: Omit<ButtonHTMLAttributes<HTMLButtonElement>, "type" | "children"> | undefined`: Optional submit button props value accepted by this exported component.
- `TidalContactForm.submitLabel?: string | undefined` (default "Send message"): Optional submit label value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/contact-form.tsx) | [Manifest](https://tidalui.com/examples/contact-form.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, useLayoutEffect, useRef, useState, type FormEvent, type InvalidEvent } from "react";

import { RotateCcw } from "lucide-react";

import { TidalContactForm, type TidalContactFormStatus, type TidalContactIntentOption } from "./components/ui/contact-form";

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



const tidalExampleStyles = ".tidal-scope .contact-form-demo {\n  width: 100%;\n  max-width: 980px;\n  min-width: 0;\n  overflow: hidden;\n  border: 1px solid var(--t-border);\n  border-radius: var(--t-radius-card);\n  background: var(--t-subtle);\n  color: var(--t-ink);\n  box-shadow: 0 25px 54px -38px #0000005c;\n  container-type: inline-size;\n}\n\n.tidal-scope .contact-form-demo-layout {\n  display: grid;\n  grid-template-columns: minmax(0, 1fr);\n  min-width: 0;\n}\n\n.tidal-scope .contact-form-demo,\n.tidal-scope .contact-form-demo * {\n  box-sizing: border-box;\n}\n\n.tidal-scope .contact-form-demo-stage {\n  display: grid;\n  place-items: center;\n  min-width: 0;\n  padding: 28px;\n  background:\n    linear-gradient(var(--t-border) 1px, transparent 1px),\n    linear-gradient(90deg, var(--t-border) 1px, transparent 1px),\n    var(--t-subtle);\n  background-size: 22px 22px;\n}\n\n.tidal-scope .contact-form-demo-stage > .tidal-contact-form {\n  max-width: 700px;\n}\n\n.tidal-scope .contact-form-demo-footer {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 12px;\n  min-width: 0;\n}\n\n.tidal-scope .contact-form-demo-footer > span {\n  min-width: 0;\n}\n\n.tidal-scope .contact-form-demo-footer > button {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  gap: 7px;\n  min-width: 44px;\n  min-height: 44px;\n  flex: none;\n  padding: 8px 10px;\n  border: 1px solid var(--t-border);\n  border-radius: 9px;\n  background: var(--t-surface);\n  color: var(--t-ink);\n  font: inherit;\n  font-size: 11px;\n  cursor: pointer;\n  transition:\n    background 160ms,\n    transform 140ms var(--t-ease-out);\n}\n\n.tidal-scope .contact-form-demo-footer > button:hover {\n  background: var(--t-wash);\n}\n\n.tidal-scope .contact-form-demo-footer > button:active {\n  transform: scale(0.98);\n}\n\n.tidal-scope .contact-form-demo-footer > button:focus-visible {\n  outline: 2px solid var(--t-accent);\n  outline-offset: 3px;\n}\n\n@container (max-width: 720px) {\n  .tidal-scope .contact-form-demo-layout {\n    grid-template-columns: minmax(0, 1fr);\n  }\n}\n\n@container (max-width: 430px) {\n  .tidal-scope .contact-form-demo-stage {\n    padding: 12px;\n    background-size: 18px 18px;\n  }\n\n  .tidal-scope .contact-form-demo-footer {\n    align-items: flex-start;\n    flex-direction: column;\n  }\n\n  .tidal-scope .contact-form-demo-footer > button {\n    width: 100%;\n  }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  \n  .tidal-scope .contact-form-demo-stage {\n    animation: none;\n    opacity: 1;\n    transform: none;\n  }\n\n  \n  .tidal-scope .contact-form-demo-footer > button {\n    transform: none;\n    transition: none;\n  }\n}\n\n@media (prefers-reduced-motion: no-preference) {\n  @keyframes contact-form-demo-enter {\n    from {\n      opacity: 0;\n      transform: translateY(10px);\n    }\n    to {\n      opacity: 1;\n      transform: translateY(0);\n    }\n  }\n\n  \n  .tidal-scope .contact-form-demo-stage {\n    animation: contact-form-demo-enter 560ms var(--t-ease-out) both;\n  }\n\n  .tidal-scope .contact-form-demo-stage {\n    animation-delay: 70ms;\n  }\n}";

const INTENT_OPTIONS = [
  {
    id: "project",
    label: "A project conversation",
    description: "Explore a focused product need",
  },
  {
    id: "sales",
    label: "A product walkthrough",
    description: "See how a team could use it",
  },
  {
    id: "partnership",
    label: "A partnership question",
    description: "Discuss a possible collaboration",
  },
] as const satisfies readonly TidalContactIntentOption[];

type ContactFocusTarget = "name" | "email" | "message";

export function ContactFormDemo() {
  const [name, setName] = useState("");
  const [email, setEmail] = useState("");
  const [company, setCompany] = useState("");
  const [message, setMessage] = useState("");
  const [intent, setIntent] = useState<string>(INTENT_OPTIONS[0].id);
  const [status, setStatus] = useState<TidalContactFormStatus>("idle");
  const [statusMessage, setStatusMessage] = useState("");
  const [nameError, setNameError] = useState("");
  const [emailError, setEmailError] = useState("");
  const [messageError, setMessageError] = useState("");
  const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
  const nameInput = useRef<HTMLInputElement>(null);
  const emailInput = useRef<HTMLInputElement>(null);
  const messageInput = useRef<HTMLTextAreaElement>(null);
  const statusElement = useRef<HTMLDivElement>(null);
  const focusNameOnIdle = useRef(false);
  const focusErrorOnRender = useRef(false);
  const focusTarget = useRef<ContactFocusTarget>("name");

  useEffect(() => () => clearTimeout(timer.current), []);

  useLayoutEffect(() => {
    if (status === "success" && document.activeElement === document.body) {
      statusElement.current
        ?.querySelector<HTMLButtonElement>("button")
        ?.focus({ preventScroll: true });
    }
    if (status === "error" && focusErrorOnRender.current) {
      focusErrorOnRender.current = false;
      const target = focusTarget.current;
      const refs = {
        name: nameInput,
        email: emailInput,
        message: messageInput,
      };
      refs[target].current?.focus({ preventScroll: true });
      return;
    }

    if (status === "idle" && focusNameOnIdle.current) {
      focusNameOnIdle.current = false;
      const target = focusTarget.current;
      focusTarget.current = "name";
      const refs = {
        name: nameInput,
        email: emailInput,
        message: messageInput,
      };
      refs[target].current?.focus({ preventScroll: true });
    }
  }, [messageError, nameError, emailError, status]);

  function clearStatus() {
    clearTimeout(timer.current);
    if (status !== "idle") {
      setStatus("idle");
      setStatusMessage("");
    }
  }

  function handleInvalid(
    event: InvalidEvent<HTMLInputElement | HTMLTextAreaElement>,
  ) {
    const field = event.currentTarget;
    const target: ContactFocusTarget | undefined =
      field.name === "name" ||
      field.name === "email" ||
      field.name === "message"
        ? field.name
        : undefined;
    if (target && !focusErrorOnRender.current) {
      focusTarget.current = target;
    }
    focusErrorOnRender.current = true;
    setStatus("error");
    setStatusMessage("Review the highlighted sample fields before continuing.");
    if (field.name === "name") {
      setNameError(
        field.validity.valueMissing
          ? "Add a name for this sample."
          : "Use a readable name.",
      );
    } else if (field.name === "email") {
      setEmailError(
        field.validity.valueMissing
          ? "Add a work email for this sample."
          : "Use a complete work email address.",
      );
    } else if (field.name === "message") {
      setMessageError("Add a short note for this sample.");
    }
  }

  function handleSubmit(event: FormEvent<HTMLFormElement>) {
    event.preventDefault();
    clearTimeout(timer.current);
    setNameError("");
    setEmailError("");
    setMessageError("");
    focusErrorOnRender.current = false;
    focusTarget.current = "name";
    setStatus("pending");
    setStatusMessage("Preparing this sample locally. Nothing is being sent.");
    timer.current = setTimeout(() => {
      setStatus("success");
      setStatusMessage(
        "Sample prepared locally. Nothing was sent, delivered, or saved.",
      );
    }, 680);
  }

  function editSample() {
    clearTimeout(timer.current);
    if (status !== "error") focusTarget.current = "name";
    focusNameOnIdle.current = true;
    setStatus("idle");
    setStatusMessage("");
  }

  function clearSample() {
    clearTimeout(timer.current);
    setName("");
    setEmail("");
    setCompany("");
    setMessage("");
    setIntent(INTENT_OPTIONS[0].id);
    setNameError("");
    setEmailError("");
    setMessageError("");
    focusErrorOnRender.current = false;
    focusTarget.current = "name";
    focusNameOnIdle.current = true;
    setStatus("idle");
    setStatusMessage("");
  }

  return (
    <section className="contact-form-demo" data-status={status}>
      <div className="contact-form-demo-layout">
        <div className="contact-form-demo-stage">
          <TidalContactForm
            title="Contact the team"
            description="Use sample values to preview the form."
            headingLevel="h3"
            nameRef={nameInput}
            emailRef={emailInput}
            messageRef={messageInput}
            statusRef={statusElement}
            status={status}
            statusMessage={statusMessage}
            statusActionLabel={
              status === "error"
                ? "Review fields"
                : status === "success"
                  ? "Edit sample"
                  : undefined
            }
            onStatusAction={editSample}
            pendingLabel="Preparing sample"
            submitLabel="Prepare sample"
            onSubmit={handleSubmit}
            intentOptions={INTENT_OPTIONS}
            intent={intent}
            onIntentChange={(option) => setIntent(option.id)}
            intentSelectProps={{
              onChange: () => clearStatus(),
            }}
            nameError={nameError}
            emailError={emailError}
            messageError={messageError}
            nameInputProps={{
              value: name,
              placeholder: "Your name",
              onChange: (event: import("react").ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
                setName(event.target.value);
                setNameError("");
                clearStatus();
              },
              onInvalid: handleInvalid,
            }}
            emailInputProps={{
              value: email,
              placeholder: "name@company.com",
              inputMode: "email",
              onChange: (event: import("react").ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
                setEmail(event.target.value);
                setEmailError("");
                clearStatus();
              },
              onInvalid: handleInvalid,
            }}
            companyInputProps={{
              value: company,
              placeholder: "Company or team",
              onChange: (event: import("react").ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
                setCompany(event.target.value);
                clearStatus();
              },
            }}
            messageInputProps={{
              value: message,
              placeholder: "A few useful details, goals, or questions",
              rows: 5,
              onChange: (event: import("react").ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
                setMessage(event.target.value);
                setMessageError("");
                clearStatus();
              },
              onInvalid: handleInvalid,
            }}
            footer={
              <div className="contact-form-demo-footer">
                <span>Local preview. Sample values only.</span>
                <button type="button" onClick={clearSample}>
                  <RotateCcw size={14} aria-hidden="true" />
                  Clear sample
                </button>
              </div>
            }
          />
        </div>
      </div>
    </section>
  );
}

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

title is required. The root forwards native form attributes/ref, including action, method, target, noValidate, onSubmit and a composed onReset. Optional description, eyebrow, headingLevel, labels, native nameInputProps/emailInputProps/companyInputProps/messageInputProps/intentSelectProps, field refs, formErrorRef and statusRef. The optional intent selector defaults to name="intent" and supports controlled intent, defaultIntent and onIntentChange; controlled reset remains caller-owned, while an unprevented reset restores uncontrolled intent to defaultIntent or the first option. Consumer-owned status ('idle' | 'pending' | 'success' | 'error'), statusMessage, statusActionLabel/onStatusAction, errors, pending and submit labels are rendered with native validation semantics. submitButtonProps forwards native submitter attributes including formAction/formMethod/formTarget, while the component preserves required field types and native form behavior. The component never sends, stores, logs or validates against a backend; the consumer owns delivery and persistence.
