Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Buttons

  • Button
  • ShimmerButton
  • InteractiveHoverButton
  • RainbowButton
  • PulsatingButton
  • RippleButton
  • ButtonGroup
  • SocialButton

Basic Inputs

  • Input
  • Textarea
  • CellEditor
  • Select
  • Checkbox
  • CheckboxGroup
  • Radio
  • Switch
  • Toggle
  • Segmented
  • Slider
  • NumberField
  • ElasticSlider

Advanced Inputs

  • MathTextarea
  • QuestionEditor
  • QuestionAnswer
  • MathField
  • SecretField
  • PasswordGenerator
  • Combobox
  • RemoteSelect
  • Listbox
  • Mentions
  • InputOTP
  • Rating
  • Upload
  • RegionSelect
  • ImageCropper
  • ScopeMatrix
  • Transfer
  • Cascader
  • TreeSelect
  • RegionCascader
  • CountrySelect
  • MarkdownEditor
  • Novel editor
  • RichTextEditor
  • CodeEditor
  • IssueReporter
  • ColorPicker
  • ColorField
  • ColorSwatchPicker
  • Choicebox
  • EmojiPicker
  • VoiceRecord
  • IconPicker
  • InspectorPanel

Date and Time

  • Calendar
  • DatePicker
  • DateTimePicker
  • DateRangePicker
  • TimePicker
  • TimeField

Form Frameworks

  • Form
  • ModalForm / DrawerForm
  • ProForm
  • StepsForm
  • LoginForm
  • AuthPanel
  • ClickCaptcha
  • Label
  • Field
  • SearchForm

Mentions

mentions

Suggests and inserts mention tokens while the user types structured text.

Usage

Basic usage

Enter @ to evoke the candidate floating layer, select with the arrow keys, and insert mention by Enter/Tab.

tsx
<Mentions
  options={people}
  placeholder="Enter @ to mention a colleague..."
  onChange={setValue}
  onSelect={(o) => console.log(o)}
/>

Custom trigger

prefix is changed to "#" to associate non-personnel entities such as work orders.

Related
tsx
<Mentions
  prefix="#"
  options={tickets}
  placeholder="Enter # associated work order..."
/>

Invalid state

invalid is marked with a red border and lacks mention in conjunction with the form verification prompt.

Missing @person in charge
tsx
<Mentions options={people} invalid defaultValue="Missing @person in charge" />

Disabled

disabled Editing is prohibited, and the submitted mention will still be displayed in color.

Disabled @Lin Xiao
tsx
<Mentions options={people} disabled defaultValue="Disabled @Lin Xiao" />

When to use

Use Mentions when free-form multiline text needs inline references, such as mentioning a person with @ or linking a ticket with #. It behaves like a Textarea until a configured trigger opens the suggestion popup. Unlike Combobox, which selects the field's entire value, Mentions inserts references into otherwise ordinary text.

Import

ts
import { Mentions, MentionText, type MentionTextProps, findTrigger, insertMention, defaultFilter, segmentMentions, type MentionSegment } from "@hulianui/ui"

Props

NameTypeDefaultDescription
options*MentionOption[]-Suggestions containing value and label, with optional description, startContent, and disabled.
valuestring-Controlled text value; pair with onChange.
defaultValuestring-Initial text when uncontrolled.
prefixstring"@"Trigger, including multi-character values such as "@@" or "#". Suggestions open only at the start of a line or after whitespace.
filterfalse | ((option, query) => boolean)Built-in substring matchPass false to disable local filtering and use onSearch, or pass a function for custom filtering. The default matches label and value case-insensitively.
size"sm" | "md" | "lg""md"Textarea visual size.
invalidbooleanfalseApplies invalid styling when used outside Field.
placeholderstring-Placeholder passed to the textarea.
rowsnumber3Row count passed to the textarea.
disabledbooleanfalseDisables the input.
classNamestring-Additional class name for the field container.
popupClassNamestring-Additional class name for the suggestion popup.
Also accepts native Textarea attributes except size, value, defaultValue, onChange, onSelect, and prefix, which use the component-specific contracts above.

Events

EventTypeDescription
onChange(value: string) => voidCalled when text changes; required when controlled.
onSearch(query: string) => voidReports query changes for external or asynchronous filtering; it does not return results.
onSelect(option: MentionOption) => voidCalled with the complete selected option.

Example

tsx
<Mentions
  options={people}
  defaultValue="Please ask "
  placeholder="Type @ to mention a colleague…"
  onSelect={(o) => console.log(o)}
/>

Use # to reference a ticket:

tsx
<Mentions prefix="#" options={tickets} placeholder="Type # to link a ticket…" />

Usage guidelines

  • Pair a controlled value with onChange; otherwise the field is read-only, just like a native controlled textarea.
  • Inserted text is prefix + label + " "; label is both the visible name and the literal stored in the text. Use onSelect to handle cases where display and stored values must differ.
  • For external or asynchronous filtering, set filter={false} and refresh options from onSearch; otherwise the built-in substring filter will filter the consumer's results a second time.
  • The suggestions listbox accessible name reads ConfigProvider's locale.components.mentions.suggestions. zhCN and enUS include it; legacy custom locales that omit this optional field retain the Chinese fallback.

Related

SecretField · Combobox · Listbox · InputOTP · Rating · Upload

Playground

<Mentions
  prefix="@"
  size="md"
  options={people}
  placeholder="Enter @ to mention a colleague..."
  rows={3}
  onChange={setValue}
  onSelect={(o) => console.log(o)}
/>
PreviousListboxFormsNextInputOTP

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Example
    • Usage guidelines
    • Related
  • Playground