# Model selector

Search and compare a consumer-supplied model catalog, then choose a model and mode with exact native form values.

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

## When to use

- Use it when a page needs search and compare a consumer-supplied model catalog, then choose a model and mode with exact native form values.
- 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 model selector.

## 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 Model selector

```sh
npx shadcn@latest add @tidal-pro/model-selector
```

Stylesheets: `components/ui/tidal.css`, `components/ui/model-selector.css`.

## Minimal example

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

## Structured props

- `TidalModelSelector.groups: ReadonlyArray<TidalModelGroup>`: Required groups value accepted by this exported component.
- `TidalModelSelector.onModeChange: (modeId: string, event: SelectionEvent) => void`: Callback invoked when the mode change interaction is proposed.
- `TidalModelSelector.onModelChange: (modelId: string, event: SelectionEvent) => void`: Callback invoked when the model change interaction is proposed.
- `TidalModelSelector.onQueryChange: (query: string, event: ChangeEvent<HTMLInputElement>) => void`: Callback invoked when the query change interaction is proposed.
- `TidalModelSelector.query: string`: Required query value accepted by this exported component.
- `TidalModelSelector.selectedModeId: string | null`: Required selected mode id value accepted by this exported component.
- `TidalModelSelector.selectedModelId: string | null`: Required selected model id value accepted by this exported component.
- `TidalModelSelector.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalModelSelector.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalModelSelector.empty?: ReactNode` (default "No models match this search."): Optional empty value accepted by this exported component.
- `TidalModelSelector.footer?: ReactNode`: Optional footer value accepted by this exported component.
- `TidalModelSelector.form?: string | undefined`: Optional form value accepted by this exported component.
- `TidalModelSelector.labels?: Partial<{ search: string; searchPlaceholder: string; models: string; modes: string; context: string; cost: string; capabilities: string; available: string; preview: string; unavailable: string; results: (visible: number, total: number) => string; choose: string; invalid: string; unknownModel: string; unknownMode: string; selectionOutsideResults: string; }> | undefined`: Optional labels value accepted by this exported component.
- `TidalModelSelector.modeInputProps?: HiddenInputProps | undefined`: Optional mode input props value accepted by this exported component.
- `TidalModelSelector.modeInputRef?: Ref<HTMLInputElement> | undefined`: Optional mode input ref value accepted by this exported component.
- `TidalModelSelector.modelInputProps?: HiddenInputProps | undefined`: Optional model input props value accepted by this exported component.
- `TidalModelSelector.modelInputRef?: Ref<HTMLInputElement> | undefined`: Optional model input ref value accepted by this exported component.
- `TidalModelSelector.modelName?: string | undefined`: Optional model name value accepted by this exported component.
- `TidalModelSelector.modeName?: string | undefined`: Optional mode name value accepted by this exported component.
- `TidalModelSelector.searchInputProps?: SearchInputProps | undefined`: Optional search input props value accepted by this exported component.
- `TidalModelSelector.searchInputRef?: Ref<HTMLInputElement> | undefined`: Optional search input ref value accepted by this exported component.
- `TidalModelSelector.title?: ReactNode` (default "Choose a model"): Optional title value accepted by this exported component.

## Complete usage example

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

import { TidalModelSelector, type TidalModelGroup } from "./components/ui/model-selector";

import "./components/ui/model-selector.css";



const tidalExampleStyles = ".model-selector-demo {\n  container: model-selector-demo / inline-size;\n  display: grid;\n  gap: 14px;\n  width: min(100%, 940px);\n  min-width: 0;\n}\n\n.model-selector-demo-actions {\n  display: flex;\n  flex-wrap: wrap;\n  justify-content: end;\n  gap: 8px;\n}\n\n.model-selector-demo-actions button {\n  min-width: 112px;\n  min-height: 44px;\n  padding: 10px 16px;\n  color: var(--t-surface);\n  background: var(--t-ink);\n  border: 1px solid var(--t-ink);\n  border-radius: 10px;\n  font: inherit;\n  font-size: 12px;\n  font-weight: 600;\n  cursor: pointer;\n  transition:\n    transform 140ms var(--t-ease-out),\n    background 180ms var(--t-ease-out),\n    color 180ms var(--t-ease-out);\n}\n\n.model-selector-demo-actions button:last-child {\n  color: var(--t-ink);\n  background: var(--t-surface);\n  border-color: var(--t-border);\n}\n\n.model-selector-demo-actions button:hover {\n  transform: translateY(-1px);\n}\n\n.model-selector-demo-actions button:active {\n  transform: scale(0.98);\n}\n\n.model-selector-demo-status {\n  margin: 0;\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.5;\n  text-align: end;\n  overflow-wrap: anywhere;\n}\n\n@container model-selector-demo (max-width: 420px) {\n  .model-selector-demo-actions {\n    display: grid;\n    grid-template-columns: repeat(2, minmax(0, 1fr));\n  }\n\n  .model-selector-demo-actions button {\n    min-width: 0;\n    font-size: 16px;\n  }\n\n  .model-selector-demo-status {\n    text-align: start;\n  }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .model-selector-demo-actions button {\n    transition: none;\n  }\n\n  .model-selector-demo-actions button:hover,\n  .model-selector-demo-actions button:active {\n    transform: none;\n  }\n}";

const groups: readonly TidalModelGroup[] = [
  {
    id: "everyday",
    label: "Everyday work",
    searchText: "writing summaries planning fast",
    description: "Responsive sample models for routine workspace tasks.",
    models: [
      {
        id: "tide-swift",
        label: "Tide Swift",
        accessibleLabel: "Tide Swift, available",
        searchText: "fast writing summary extraction",
        description: "Quick drafts and structured extraction.",
        context: "64K sample tokens",
        cost: "1 sample credit",
        capabilities: ["Text", "Structured output", "Fast response"],
        modes: [
          {
            id: "quick",
            label: "Quick",
            accessibleLabel: "Quick mode",
            description: "Lowest delay",
          },
          {
            id: "balanced",
            label: "Balanced",
            accessibleLabel: "Balanced mode",
            description: "More review",
          },
        ],
      },
      {
        id: "tide-reason",
        label: "Tide Reason",
        accessibleLabel: "Tide Reason, available",
        searchText: "analysis planning code reasoning",
        description: "Longer analysis for plans and technical work.",
        context: "128K sample tokens",
        cost: "3 sample credits",
        capabilities: ["Text", "Code", "Tool plans"],
        modes: [
          {
            id: "balanced",
            label: "Balanced",
            accessibleLabel: "Balanced mode",
            description: "Everyday depth",
          },
          {
            id: "careful",
            label: "Careful",
            accessibleLabel: "Careful mode",
            description: "Extra review",
          },
          {
            id: "deep",
            label: "Deep",
            accessibleLabel: "Deep mode",
            description: "Longest analysis",
          },
        ],
      },
    ],
  },
  {
    id: "specialist",
    label: "Specialist",
    searchText: "image vision archive preview",
    description: "Focused sample models with narrower capabilities.",
    models: [
      {
        id: "tide-vision",
        label: "Tide Vision",
        accessibleLabel: "Tide Vision, preview",
        searchText: "image screenshot diagram visual",
        description: "Reads screenshots, diagrams and product imagery.",
        availability: "preview",
        context: "96K sample tokens",
        cost: "2 sample credits",
        capabilities: ["Images", "Text", "Layout review"],
        modes: [
          {
            id: "balanced",
            label: "Balanced",
            accessibleLabel: "Balanced mode",
            description: "Mixed media",
          },
          {
            id: "detail",
            label: "Detail",
            accessibleLabel: "Detail mode",
            description: "Fine inspection",
          },
        ],
      },
      {
        id: "tide-archive",
        label: "Tide Archive",
        accessibleLabel: "Tide Archive, unavailable",
        searchText: "large archive documents",
        description: "Large archive review is unavailable in this sample.",
        availability: "unavailable",
        context: "256K sample tokens",
        cost: "Unavailable",
        capabilities: ["Documents", "Long context"],
      },
    ],
  },
];

const findModel = (id: string) =>
  groups.flatMap((group) => group.models).find((model) => model.id === id);

export function ModelSelectorDemo() {
  const formId = `model-selector-demo-${useId().replace(/:/g, "")}`;
  const searchRef = useRef<HTMLInputElement>(null);
  const [query, setQuery] = useState("");
  const [modelId, setModelId] = useState("tide-reason");
  const [modeId, setModeId] = useState("balanced");
  const [status, setStatus] = useState(
    "Tide Reason with Balanced mode is selected locally.",
  );

  const chooseModel = (nextModelId: string) => {
    const model = findModel(nextModelId);
    const nextMode = model?.modes?.find((mode) => !mode.disabled)?.id ?? null;
    setModelId(nextModelId);
    setModeId(nextMode ?? "");
    setStatus(`${model?.accessibleLabel ?? nextModelId} selected locally.`);
  };

  const submit = (event: FormEvent<HTMLFormElement>) => {
    event.preventDefault();
    const data = new FormData(event.currentTarget);
    const model = findModel(String(data.get("sample-model") ?? ""));
    const mode = model?.modes?.find(
      (item) => item.id === data.get("sample-mode"),
    );
    setStatus(
      `Prepared ${model?.accessibleLabel ?? "the model"}${mode ? ` in ${mode.accessibleLabel}` : ""} for this local preview.`,
    );
  };

  const reset = () => {
    setQuery("");
    setModelId("tide-reason");
    setModeId("balanced");
    setStatus("The sample selection was reset.");
    searchRef.current?.focus({ preventScroll: true });
  };

  return (
    <form id={formId} className="model-selector-demo" onSubmit={submit}>
      <TidalModelSelector
        title="Choose a workspace model"
        description="Compare available sample capabilities, context and cost."
        groups={groups}
        query={query}
        onQueryChange={setQuery}
        selectedModelId={modelId || null}
        selectedModeId={modeId || null}
        onModelChange={chooseModel}
        onModeChange={(nextModeId) => {
          setModeId(nextModeId);
          setStatus(`${nextModeId} mode selected locally.`);
        }}
        modelName="sample-model"
        modeName="sample-mode"
        searchInputRef={searchRef}
        footer="Fictional catalog and sample credits. No provider request is made."
      />
      <div className="model-selector-demo-actions">
        <button type="submit">Use selection</button>
        <button type="button" onClick={reset}>
          Reset
        </button>
      </div>
      <p className="model-selector-demo-status" role="status">
        {status}
      </p>
    </form>
  );
}

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

Consumer-owned groups contain unique non-empty IDs, labels, optional descriptions/search text and typed model records. Models and modes provide exact IDs and nonblank accessible labels; models may also provide description, availability, context, cost, capabilities and search text. Controlled query, selectedModelId and selectedModeId produce proposals through native search, click and plain Arrow/Home/End radio-key events; caller handlers run first and prevention suppresses proposals. Consumers own the catalog, availability, costs, selection acceptance, filtering semantics and downstream requests. A selected model outside filtered results remains visible with an explicit localized status. Optional modelName/modeName serialize the exact controlled IDs through native hidden inputs and external form association. Root/search/model/mode refs and native prop bags, disabled state including selected-model modes, empty and configuration errors, numeric content, 44px choices, 16px narrow search, RTL, forced colors and reduced motion are supported. Choice ARIA roles, checked state, labels, tab order and disabled semantics are component-owned. No provider calls, model discovery, pricing lookup, authentication, storage or inference occurs.
