Data Entry

Mentions

A textarea that detects trigger characters like @ and shows a filtered dropdown of suggestions. Keyboard-navigable and fully accessible.

Type @ followed by a name to trigger autocomplete.

Installation

npx benflux-ui add mentions

Multiple prefixes

// Trigger @ for users, # for issues
<Mentions
  prefix={["@", "#"]}
  options={[
    { value: "alice", label: "Alice Martin" },
    { value: "42", label: "#42 — Fix login bug" },
  ]}
  placeholder="Use @ for users, # for issues..."
/>

Custom filter

<Mentions
  options={users}
  filterOption={(input, option) =>
    option.label?.toLowerCase().startsWith(input.toLowerCase()) ?? false
  }
/>

Props

PropTypeDefaultDescription
options*MentionOption[]List of mentionable items
valuestringControlled textarea value
defaultValuestring""Initial value (uncontrolled)
onChange(value: string) => voidCalled on every change
onSelect(option: MentionOption, prefix: string) => voidCalled when a suggestion is selected
prefixstring | string[]"@"Trigger character(s)
splitstring" "Character appended after the mention
placeholderstringTextarea placeholder
rowsnumber4Number of visible rows
disabledbooleanfalseDisable the textarea
filterOptionboolean | ((input, option) => boolean)trueClient-side filtering
notFoundContentReactNode"No matches"Shown when no options match

MentionOption

interface MentionOption {
  value: string        // Inserted into the textarea
  label?: string       // Display name in the dropdown
  avatar?: string      // Avatar image URL
  description?: string // Subtitle shown below the label
}