# Mention input

Write native textarea content and insert people or records from supplied suggestions.

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

## When to use

- Use it when a page needs write native textarea content and insert people or records from supplied suggestions.
- 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 mention input.

## 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 Mention input

```sh
npx shadcn@latest add @tidal-pro/mention-input
```

Stylesheets: `components/ui/tidal.css`, `components/ui/mention-input.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/mention-input.css";
import{TidalMentionInput}from"./components/ui/mention-input";
export default()=><div className="tidal-scope"><TidalMentionInput label={"Demo"} onValueChange={() => {}} suggestions={[{id:"example",label:"Demo",value:"value"}]} value={"value"}/></div>;
```

## Structured props

- `TidalMentionInput.label: ReactNode`: Required label value accepted by this exported component.
- `TidalMentionInput.onValueChange: (value: string) => void`: Callback invoked when the value change interaction is proposed.
- `TidalMentionInput.suggestions: ReadonlyArray<TidalMentionSuggestion>`: Required suggestions value accepted by this exported component.
- `TidalMentionInput.value: string`: Required value value accepted by this exported component.
- `TidalMentionInput.aria-disabled?: Booleanish | undefined`: Accessible disabled supplied by the consumer.
- `TidalMentionInput.aria-invalid?: boolean | "true" | "false" | "grammar" | "spelling" | undefined`: Accessible invalid supplied by the consumer.
- `TidalMentionInput.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalMentionInput.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalMentionInput.emptyMessage?: ReactNode` (default "No matching suggestions."): Optional empty message value accepted by this exported component.
- `TidalMentionInput.error?: ReactNode`: Optional error value accepted by this exported component.
- `TidalMentionInput.maxSuggestions?: number | undefined` (default 6): Optional max suggestions value accepted by this exported component.
- `TidalMentionInput.onChange?: ChangeEventHandler<HTMLTextAreaElement, HTMLTextAreaElement> | undefined`: Callback invoked when the change interaction is proposed.
- `TidalMentionInput.onMentionSelect?: ((suggestion: TidalMentionSuggestion, nextValue: string) => void) | undefined`: Callback invoked when the mention select interaction is proposed.
- `TidalMentionInput.readOnly?: boolean | undefined` (default false): Optional read only value accepted by this exported component.
- `TidalMentionInput.rootClassName?: string | undefined` (default ""): Optional root class name value accepted by this exported component.
- `TidalMentionInput.suggestionsLabel?: string | undefined` (default "Mention suggestions"): Optional suggestions label value accepted by this exported component.
- `TidalMentionInput.trigger?: string | undefined` (default "@"): Optional trigger value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/mention-input.tsx) | [Manifest](https://tidalui.com/examples/mention-input.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 { useState } from "react";

import { TidalMentionInput, type TidalMentionSuggestion } from "./components/ui/mention-input";

import "./components/ui/mention-input.css";



const tidalExampleStyles = ".tidal-scope .mention-input-demo {\n  container: mention-input-demo / inline-size;\n  display: grid;\n  gap: 20px;\n  width: min(100%, 560px);\n  min-width: 0;\n  color: var(--t-ink);\n}\n\n.tidal-scope .mention-input-demo-actions {\n  display: flex;\n  flex-wrap: wrap;\n  gap: 10px;\n}\n\n.tidal-scope .mention-input-demo-actions > button {\n  min-width: 126px;\n  min-height: 44px;\n  padding: 10px 15px;\n  border: 1px solid var(--t-border);\n  border-radius: var(--t-radius-control);\n  background: var(--t-surface);\n  color: var(--t-ink);\n  font: inherit;\n  font-size: 13px;\n  font-weight: 650;\n  cursor: pointer;\n  transition:\n    border-color 140ms,\n    background-color 140ms,\n    color 140ms,\n    transform 140ms var(--t-ease-out);\n}\n\n.tidal-scope .mention-input-demo-actions > button[type=\"submit\"] {\n  border-color: var(--t-ink);\n  background: var(--t-ink);\n  color: var(--t-surface);\n}\n\n.tidal-scope .mention-input-demo-actions > button:hover {\n  border-color: var(--t-ink);\n}\n\n.tidal-scope .mention-input-demo-actions > button[type=\"reset\"]:hover {\n  background: var(--t-ink);\n  color: var(--t-surface);\n}\n\n.tidal-scope .mention-input-demo-actions > button:active {\n  transform: scale(0.98);\n}\n\n.tidal-scope .mention-input-demo-actions > button:focus-visible {\n  outline: 2px solid var(--t-accent);\n  outline-offset: 3px;\n}\n\n.tidal-scope .mention-input-demo-status {\n  min-width: 0;\n  margin: 0;\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.5;\n  overflow-wrap: anywhere;\n}\n\n@container mention-input-demo (max-width: 320px) {\n  .tidal-scope .mention-input-demo-actions {\n    display: grid;\n    grid-template-columns: minmax(0, 1fr);\n  }\n\n  .tidal-scope .mention-input-demo-actions > button {\n    width: 100%;\n  }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .tidal-scope .mention-input-demo-actions > button {\n    transition: none;\n  }\n\n  .tidal-scope .mention-input-demo-actions > button:active {\n    transform: none;\n  }\n}";

const INITIAL_MESSAGE = "Review this with @";

const PEOPLE: readonly TidalMentionSuggestion[] = [
  { id: "ava", label: "Ava Reed", value: "ava", description: "Design" },
  { id: "noah", label: "Noah Kim", value: "noah", description: "Product" },
  { id: "mila", label: "Mila Chen", value: "mila", description: "Research" },
  { id: "sam", label: "Sam Ortiz", value: "sam", description: "Engineering" },
];

export function MentionInputDemo() {
  const [message, setMessage] = useState(INITIAL_MESSAGE);
  const [error, setError] = useState<string | null>(null);
  const [status, setStatus] = useState(
    "Type @ to choose a fictional teammate.",
  );

  return (
    <form
      className="mention-input-demo"
      aria-label="Mention input preview"
      onSubmit={(event) => {
        event.preventDefault();
        const submitted = new FormData(event.currentTarget).get("message");
        setError(null);
        setStatus(`Prepared locally: ${String(submitted)}`);
      }}
      onReset={(event) => {
        if (event.defaultPrevented) return;
        setMessage(INITIAL_MESSAGE);
        setError(null);
        setStatus("Sample reset.");
      }}
    >
      <TidalMentionInput
        name="message"
        label="Review note"
        value={message}
        onValueChange={(nextValue) => {
          setMessage(nextValue);
          setError(null);
          setStatus("Type @ to choose a fictional teammate.");
        }}
        suggestions={PEOPLE}
        onMentionSelect={(person) =>
          setStatus(`${person.label} added to the local note.`)
        }
        description="Suggestions are supplied by this local sample."
        error={error}
        placeholder="Write a note and type @"
        required
        onInvalid={(event) => {
          event.preventDefault();
          setError("Write a review note.");
          setStatus("Check the note.");
          event.currentTarget.focus({ preventScroll: true });
        }}
      />

      <div className="mention-input-demo-actions">
        <button type="submit">Prepare note</button>
        <button type="reset">Reset</button>
      </div>
      <p className="mention-input-demo-status" role="status" aria-live="polite">
        {status}
      </p>
    </form>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <MentionInputDemo />
    </div>
  );
}

```

## Gotchas

- Keep field state, validation results, submission, and persistence in the host form workflow.

## 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."}

Controlled string value/onValueChange with consumer-supplied typed suggestions{id,label,value,description?,insertText?,disabled?}. Optional onMentionSelect receives the selected item and exact next serialized textarea value. Optional trigger(default@), suggestionsLabel, emptyMessage, maxSuggestions(default6), description/error, disabled/readOnly/rootClassName. Native textarea name/form/required/rows/autocomplete/placeholder/input/paste/composition/focus/blur/select/click/key handlers/className/style and forwarded ref remain available; value/defaultValue/change and disabled/readOnly ARIA are owned. Trigger detection requires start, whitespace or an opening bracket; filtering matches label/value. Native textarea editing/paste/deletion serialize exactly. Keyboard Arrow keys move enabled suggestions, Enter/Tab inserts and Escape dismisses the current query. Caller handlers run first and default prevention suppresses component behavior. IME composition closes suggestions until completion. Consumers own suggestion lookup, identities, structured mention ranges, requests, persistence and submission.
