---
title: "Mention Input"
description: "A text field that turns @people and #channels into chips. A line shows who gets a notice, and the value keeps their ids, not their names."
url: https://gelatinui.com/components/mention-input
markdown_url: https://gelatinui.com/components/mention-input.md
access: free
install: "npx shadcn@latest add @gelatin-ui/mention-input"
registry_item: https://gelatinui.com/r/mention-input.json
version: "2026-11-17"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Mention Input

> A text field that turns @people and #channels into chips. A line shows who gets a notice, and the value keeps their ids, not their names.

Page: https://gelatinui.com/components/mention-input

## When to use it

Best for: A comment or a message field where people mention teammates and channels, and the app needs their ids.

- Give one trigger per list in `triggers`: `@` with the people, `#` with the channels.
- Use `search` on a trigger for a directory too big to send; it runs 150ms after the last key and aborts the older search.
- Save the value as it is: each mention is `@[label](id)`, so a renamed person still points to the right id.
- Put `MentionInputNotice` in the footer, so the writer sees who gets a notice before sending.

## When not to use it

- For plain text with no mentions, use a [Textarea](https://gelatinui.com/components/textarea.md).
- For a list of tags or emails with no text around them, use a [Tags Input](https://gelatinui.com/components/tags-input.md).

## Notes for agents

- The value is text with tokens: `Thanks @[Maya Chen](u_42) in #[checkout](c_7)`. Parse it on the server to send the notices.
- Past `maxMentions` people (default 20), the field is invalid and `MentionInputError` and `MentionInputCount` show.
- An item with `access: false` shows Give access and does not pick: handle it in `onGiveAccess`.
- Cmd or Ctrl + Enter calls `onSubmit` with the value. Reset a controlled `value` to `""` after the send.
- `readOnly` shows a sent comment: the text and chips with no field around them.
- With `name`, the value goes with the form.

## Anatomy

```text
MentionInput
├─ MentionInputContent (0..n)
├─ MentionInputFooter (0..n)
├─ MentionInputNotice (0..n)
├─ MentionInputCount (0..n)
├─ MentionInputError (0..n)
└─ MentionInputPopup (0..n)
```

## API reference

### MentionInput

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `aria-label` | `string` |  | Defines a string value that labels the current element. The name of the field for screen readers, when no visible label names it. |
| `value` | `string` |  | The saved value: text with `@[label](id)` tokens. Controlled. |
| `defaultValue` | `string` | "" | The first value when uncontrolled. Default `""`. |
| `onValueChange` | `function` |  | Called with the new value on each edit. |
| `triggers` | `readonly MentionInputTrigger[]` |  | What opens a list: `@` people, `#` channels. |
| `maxMentions` | `number` | 20 | The most people a value may mention. Past it the field is invalid. Default 20. |
| `onGiveAccess` | `function` |  | Called with a row whose person cannot see the page (`access: false`). |
| `onSubmit` | `function` |  | Called on Cmd or Ctrl + Enter with the value (send the comment). |
| `placeholder` | `string` | "" | The text of the empty field. |
| `disabled` | `boolean` | false |  |
| `readOnly` | `boolean` | false | A sent comment: the text and chips show, with no field around them. |
| `invalid` | `boolean` | false | Force the error look (a server error). The mention limit sets it by itself. |
| `name` | `string` |  | The form field name: the value goes with the form (`FormValue`). |
| `labels` | `Partial<MentionInputLabels>` |  |  |
| `children` | `ReactNode` |  | The parts. Default: the text, the footer with the notice, and the list. |

### MentionInputContent

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### MentionInputFooter

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### MentionInputNotice

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### MentionInputCount

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### MentionInputError

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### MentionInputPopup

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `arrow` | `boolean` |  | Show an arrow that points at the trigger. The gap grows from 4px to 8px. |
| `backdrop` | `boolean` |  | Put a clear layer under the popup (Base UI `Popover.Backdrop`), for example to dim it. |
| `showCloseButton` | `boolean` |  | Show a close button (a 24px ghost icon button) 10px from the top and the end. |
| `padding` | `"default" \| "none" \| "tight"` |  | `default`: radius 14, 12px padding and 10px between the parts, 288px wide. `tight`: 4px padding and 4px between the parts, as wide as the content: a row of 28px actions (a plain Toolbar) with the 4px inset of the bar recipe, 38px high (the selection pill of the Quote Reply). `none`: no padding and no gap, as wide as the content: a panel that lays out its own parts edge to edge (a head with a rule, a scroll box, a docked composer: the Chat Popup). Give it a width and a height with layout classes; the body fills that height. |
| `portalProps` | `Omit` |  | Other Base UI props of the inner parts. A `className` here adds to the component classes. |
| `positionerProps` | `PopupPartProps` |  |  |
| `backdropProps` | `PopupPartProps<PopoverBackdropProps>` |  |  |
| `arrowProps` | `PopupPartProps<PopoverArrowProps>` |  |  |
| `closeButtonProps` | `PopupPartProps` |  |  |

Also takes every prop of Base UI `Popover.Portal`: https://base-ui.com/react/components/popover

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| MentionInput | `mention-input` | `data-disabled`, `data-invalid`, `data-readonly`, `data-stage-focused` | `--radius` | `motion-timing` |
| MentionInputContent | `mention-input-content` | `data-disabled` |  |  |
| MentionInputFooter | `mention-input-footer` |  |  |  |
| MentionInputNotice | `mention-input-notice` |  |  |  |
| MentionInputCount | `mention-input-count` |  |  | `status-colors` |
| MentionInputError | `mention-input-error` |  |  | `status-colors` |
| MentionInputPopup | `mention-input-popup` |  |  |  |

## Usage

Give the triggers and their items. The content, the footer with the notice, and the list are parts.

```tsx title="comment-field.tsx"
import { useState } from "react";

import {
  MentionInput,
  MentionInputContent,
  MentionInputCount,
  MentionInputFooter,
  MentionInputNotice,
  MentionInputPopup,
} from "@/components/ui/mention-input";

const TRIGGERS = [
  {
    char: "@",
    label: "People",
    items: [
      { id: "u_42", kind: "person", label: "Maya Chen", meta: "Checkout" },
      { id: "u_19", kind: "person", label: "Tomas Novak", meta: "Payments" },
    ],
  },
  {
    char: "#",
    label: "Channels",
    items: [{ id: "c_7", kind: "item", label: "checkout", meta: "24 members", notify: 24 }],
  },
] as const;

export function CommentField() {
  const [value, setValue] = useState("");
  return (
    <MentionInput
      triggers={TRIGGERS}
      value={value}
      onValueChange={setValue}
      onSubmit={() => setValue("")}
      placeholder="Write a comment. Type @ to mention"
      aria-label="Comment"
    >
      <MentionInputContent />
      <MentionInputFooter>
        <MentionInputNotice />
        <MentionInputCount />
      </MentionInputFooter>
      <MentionInputPopup />
    </MentionInput>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/mention-input
```

It adds 40 registry items: 37 files, 5972 lines, and the npm packages `@base-ui/react`, `@phosphor-icons/react`, `@tiptap/core`, `@tiptap/extension-mention`, `@tiptap/extensions`, `@tiptap/pm`, `@tiptap/react`, `@tiptap/suggestion`, `clsx`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Avatar](https://gelatinui.com/components/avatar.md)
- [Button](https://gelatinui.com/components/button.md)
- [Dot](https://gelatinui.com/components/dot.md)
- [Popover](https://gelatinui.com/components/popover.md)
- [Skeleton](https://gelatinui.com/components/skeleton.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Textarea](https://gelatinui.com/components/textarea.md)
- [Tags Input](https://gelatinui.com/components/tags-input.md)
- [Combobox](https://gelatinui.com/components/combobox.md)
- [Avatar](https://gelatinui.com/components/avatar.md)

## Keyboard

| Keys | Action |
| --- | --- |
| @, # | Opens the list of the trigger at the caret. |
| ↑ ↓ | Moves the highlight in the open list. Focus stays in the text. |
| Enter, Tab | Puts the highlighted row in the text as a chip. |
| Escape | Closes the list and keeps the typed text. |
| Backspace | Next to a chip, selects it first. A second Backspace removes it. |
| Cmd/Ctrl + Enter | Calls `onSubmit` with the value. |
| Cmd/Ctrl + Z | Undoes the last edit. |

## Motion

| Part | Motion |
| --- | --- |
| New chip | fade · 150ms · a picked chip fades in |
| List | popup · 150ms · ease-panel · fades in and scales from 95% at the caret |
