Skip to main content

Mentions

Multi-line input with @-prefixed member suggestions; selecting writes the mention back into the text.

Basic usage​

Basic usage
Mentioned:—
import { useState } from 'react'
import { LhMentions } from '@lh-ui/react'

const members = [
{ label: 'Alice', value: 'alice' },
{ label: 'Bob', value: 'bob' },
]

export default function Demo() {
const [text, setText] = useState('')
return <LhMentions options={members} onValueChange={setText} />
}

Mentions Props​

PropDescriptionTypeValuesDefault
optionsCandidate membersMentionOption[]—[]
valueText value (controlled)string——
defaultValueDefault text value (uncontrolled)string——
onValueChangeText change callback(value: string) => void——
onSelectCandidate selected (second arg is the full text after insertion)(option, insertText) => void——
prefixTrigger prefixstring—'@'
rowsTextarea rowsnumber—3
disabledDisabledboolean—false
nameNative form name (hidden input)string——
placeholder / ariaLabel / sxCommon props———

MentionOption: { label: string; value?: string; disabled?: boolean }. The human-readable @label is written back to the text; the machine value reaches the app via onSelect.

Mentions Events​

EventDescriptionCallbackVue equivalent
onValueChangeText change(value: string) => void@input
onSelectCandidate selected(option, insertText) => void@select
Context rules

The panel activates when the caret finds the nearest prefix with no whitespace between it and the caret. Email-like pseudo prefixes (a@b.com, preceded by ASCII alphanumeric / ._%+-) do not trigger. CJK characters adjacent to the prefix (你好@张三) trigger normally.

Keyboard interaction

While the panel is open, ArrowUp / ArrowDown move the highlight and Enter selects the suggestion (no line break); Esc closes. The input exposes combobox aria attributes.

Styles​

import '@lh-ui/react/style/mentions'