Mentions

Textarea input with @mentions, #hashtags, and other triggers for autocomplete suggestions.

Basic Usage

Type @ to trigger user mentions. The dropdown appears with matching suggestions.

Type @ to mention

With Avatars

Display user avatars in the mention dropdown for better visual recognition.

Type @ to mention

Custom Trigger (#)

Use # to trigger tag suggestions for categorizing content.

Type # to mention

Channel References

Reference channels with # trigger for Slack-like mentions.

Type # to mention

Multi-line Input

Works with larger text areas for comments, messages, and posts.

Type @ to mention

API Reference

MentionsProps

PropTypeDefaultDescription
valuestring''Controlled value of the textarea
onChange(value: string) => void-Callback when value changes
onMention(option: MentionOption) => void-Callback when a mention is selected
optionsMentionOption[][]Available mention options
triggerstring'@'Character that triggers the dropdown
placeholderstring-Placeholder text
rowsnumber4Number of visible text rows
disabledbooleanfalseDisable the input
classNamestring-Additional CSS classes

MentionOption

PropertyTypeDescription
idstringUnique identifier for the option
displaystringDisplay text for the mention
avatarstringOptional avatar image URL
metadataRecord<string, any>Optional additional data

Usage

import { Mentions, type MentionOption } from '@/components/ui/mentions'

const users: MentionOption[] = [
  { id: '1', display: 'Alice Johnson', avatar: '/avatars/alice.jpg' },
  { id: '2', display: 'Bob Smith', avatar: '/avatars/bob.jpg' },
  { id: '3', display: 'Carol Williams', avatar: '/avatars/carol.jpg' },
]

function MyComponent() {
  const [value, setValue] = useState('')

  return (
    <Mentions
      value={value}
      onChange={setValue}
      options={users}
      placeholder="Type @ to mention someone..."
      onMention={(option) => {
        console.log('Mentioned:', option)
      }}
    />
  )
}