Mentions

Mentions

Form
Input
AI

A textarea with @mention autocomplete support, dropdown positioning, and keyboard navigation.

Preview

Type @ to trigger mention suggestions

Type @ to mention

Suggestions open

What the list looks like while typing @ma: one container, avatar rows, the active row highlighted

Type @ to mention

Rendered mentions

A finished message shows each mention as a chip

Thanks @Maria Garcia, I moved the review to Friday. @Marcus Lee can you pick up the API changes?

Variants

Default and filled input variants

Type @ to mention

Type @ to mention

Props

Component API reference

PropTypeDefaultDescription
valuestring''Controlled textarea value
onChange(value: string) => void—Callback when text changes
onMention(mention: MentionOption) => void—Callback when a mention is selected
optionsMentionOption[][]Available mention options with id, display, avatar, and metadata
triggerstring'@'Character that triggers the mention dropdown
placeholderstring'Type @ to mention...'Placeholder text
disabledbooleanfalseWhether the textarea is disabled
labelstring—Label text above the textarea
errorstring—Error message text
helperTextstring—Helper text below the textarea
rowsnumber4Number of visible text rows
maxHeightnumber200Maximum height in pixels
variant'default' | 'filled' | 'error''default'Visual variant
filterOption(search: string, option: MentionOption) => boolean—Custom filter function
renderOption(option: MentionOption) => ReactNode—Custom render function for dropdown options
classNamestring—Additional CSS classes

Usage

Import and implementation example

import { Mentions } from '@/components/ui/mentions'
import type { MentionOption } from '@/components/ui/mentions'
const users: MentionOption[] = [
{ id: '1', display: 'Alice Johnson', metadata: { subtitle: 'Engineering' } },
{ id: '2', display: 'Bob Smith', avatar: '/avatars/bob.jpg' },
]
export default function Example() {
const [value, setValue] = useState('')
return (
<Mentions
value={value}
onChange={setValue}
options={users}
onMention={(mention) => console.log('Mentioned:', mention)}
label="Comment"
placeholder="Type @ to mention..."
/>
)
}

Features

Built-in functionality

  • @mention trigger: Configurable trigger character to open suggestion dropdown
  • Keyboard navigation: Arrow keys, Enter/Tab to select, Escape to close
  • Auto-positioning: Dropdown positions itself near the cursor
  • Search filtering: Real-time filtering of options as you type
  • Avatar support: Display user avatars in the dropdown
  • Custom rendering: Override option rendering with renderOption prop
  • Three variants: Default, filled, and error visual styles
  • Error/helper text: Built-in error and helper text display

Accessibility

Accessibility considerations

ARIA Attributes

Uses native textarea elementLabel is associated with the textarea

Keyboard Navigation

KeyAction
ArrowDownMove to next option in dropdown
ArrowUpMove to previous option in dropdown
Enter / TabSelect the highlighted option
EscapeClose the dropdown

Notes

  • Dropdown closes when clicking outside
  • Error messages are displayed below the textarea
  • Trigger hint is shown when no error or helper text is present

Related Components