Eidetic

Mentions

Form
Input
AI

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

Preview

Type @ to trigger mention suggestions

Type @ to mention

Variants

Default and filled input variants

Type @ to mention

Type @ to mention

Props

Component API reference

PropTypeDefaultDescription
valuestring''Controlled textarea value
onChange(value: string) => voidCallback when text changes
onMention(mention: MentionOption) => voidCallback 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
labelstringLabel text above the textarea
errorstringError message text
helperTextstringHelper 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) => booleanCustom filter function
renderOption(option: MentionOption) => ReactNodeCustom render function for dropdown options
classNamestringAdditional 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