Mention input

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

npx shadcn@latest add @silicon-ui/mention-input
inputsnew
Loading…

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. Shared files are skipped if you already have them.

    • components/silicon-ui/mention-input/mention-input.tsx
    • components/silicon-ui/mention-input/mention-input.module.css
  3. Install the foundation once per app for the design and motion tokens: npx shadcn@latest add @silicon-ui/silicon-foundation

Usage

Source codetsx
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