Mention

Type a trigger character in a text field to pick a person, a tag or a command from a list.

General

Type @ and the start of a name. Arrow keys move through the list, Enter or Tab inserts the mention and Escape closes the list.

Other trigger

Change the character with trigger. Here # picks a topic.

Comment box

Keep the text in your state to read who was mentioned. The people below are the ones who will be notified.

APIs

Mention.Props

AttributeDescriptionTypeAccepted valuesDefault
optionswhat can be mentioned. value is inserted, label is shown{ value: string; label?: string; disabled?: boolean }[]--
triggercharacter that opens the liststring-@
valuetext of the field, to control itstring--
initialValuetext at the startstring-''
onChangecalled with the new text(text: string) => void--
onSelectcalled with the option that was inserted(option: MentionOption) => void--
rowsheight of the fieldnumber-3
placeholderhint while the field is emptystring--
emptyTextshown when nothing matchesstring-No results
disabledblock the fieldboolean-false
...native props of the textareaTextareaHTMLAttributes--

Accessibility

  • • The field is a textarea with aria-autocomplete="list". While the suggestions are open it points to the list with aria-controls and to the highlighted option with aria-activedescendant. The list has the listbox and option roles, and a disabled option has aria-disabled.
  • • Arrow Down and Arrow Up move through the options and skip the disabled ones, Enter or Tab choose the highlighted one, and Escape closes the list. Typing or moving the caret opens it again.
  • • A hidden status line announces how many results are available, such as 3 results available.
Edit this page on GitHub