Skip to content

Mention input

A textarea with @people and #channel mentions that act as single tokens, with suggestions at the caret.

InputsNew
npx shadcn@latest add @silicon-ui/mention-input

Installation

With the shadcn CLI

npx shadcn@latest add @silicon-ui/mention-input

Manually

  1. Install the dependencies

    npm install lucide-react motion
  2. Copy these files into your project

    • components/silicon-ui/mention-input/mention-input.tsx
    • components/silicon-ui/mention-input/mention-input.module.css

    Shared with other components. Skip any you already have.

    • components/silicon-ui/lib/fluid-hover.tsx
  3. Add the foundation, once per app, for the design and motion tokens

    npx shadcn@latest add @silicon-ui/silicon-foundation

Usage

usage.tsx
import { MentionInput } from "@/components/silicon-ui/mention-input/mention-input";

API reference

PropTypeDefault
valueMentionValue—
defaultValueMentionValue—
onChange(value: MentionValue) => void—
people

People offered after `@`. Leave it out to turn person mentions off.

MentionPerson[]—
channels

Channels offered after `#`. Leave it out to turn channel mentions off.

MentionChannel[]—
onMentionAdd

Called when a suggestion becomes a mention.

(mention: Mention) => void—
onSubmit

With `submitOnEnter`, Enter submits and Shift+Enter adds a line.

(value: MentionValue) => void—
submitOnEnterbooleanfalse
placeholderstring—
minRowsnumber1
maxRows

The field grows to this many rows, then scrolls.

number8
placement

Where suggestions open. `auto` flips above when there is no room below.

"auto" | "top" | "bottom""auto"
maxSuggestionsnumber6
disabledboolean—
namestring—
idstring—
aria-labelstring—
aria-describedbystring—
classNamestring—

Also accepts the props of HTMLAttributes.

Dependencies

npm
lucide-reactmotion
Registry
silicon-motion-tokens