Mention

Designer doc
Mention is an input component support both text and highlighted input with @ prefix.

Example

Basic Usage
View code
Serializing data
The value of Mention is using EditorState and it’s not serializable - meaning it cannot be stored directly to the backend. Instead, you should use convertFromRaw to restore from and convertToRaw to store it as a plain object to the backend.
View code
Customizing list
You can render anything inside the <MentionList>. Optionally, you can pass any data prop, which later can be used to render the mention button accordingly, like adding a Tooltip.
View code
Addons
There is built-ins addons MentionCharCount component. By default, it will count a single mention as one character. You can also customize the calculation by providing getCharCount prop.
View code
Resizing and placeholder
You can specify minRows and maxRows, by default to 6. To achieve resizing, specify resize to vertical. The placeholder will also adjust according to the height.
View code
Trigger and other configs
By default it uses @ as the trigger. You can specify mentionPrefix and mentionTrigger props to customize it. Please refer to @draft-js-plugins/mention Configuration Parameters for supported options.
View code
Caveats
MentionList iterates the children and collects the id, name, and data prop from each element. So in the following code, Tame Impala is abstracted away from App and won’t work correctly:
View code
As a display
For displaying, you can use MentionDisplay and MentionList without the MentionOption.
View code

API

Mention
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
bottomElementReactNode
bottomElementPropsHTMLAttributes<HTMLDivElement> & { ref?: Ref<HTMLDivElement>; }
disabledboolean
editorPropsPluginEditorProps & { ref?: Ref<PluginEditor>; }
initialValueEditorStateEditorState.createEmpty()
invalidboolean
maxRowsnumber
minRowsnumber
onChange(value: EditorState) => void
placeholderReactNode
placeholderPropsHTMLAttributes<HTMLDivElement> & { ref?: Ref<HTMLDivElement>; }
resizeResizenone
toolbarElementReactNode
valueEditorState
MentionButton
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
disabledboolean
Equivalent to button's disabled property.
keyboardClickKeysstring[]
onBlurFocusEventHandler<HTMLDivElement>
onClickMouseEventHandler<HTMLDivElement>
onKeyDownKeyboardEventHandler<HTMLDivElement>
onKeyUpKeyboardEventHandler<HTMLDivElement>
onMouseDownMouseEventHandler<HTMLDivElement>
onMouseLeaveMouseEventHandler<HTMLDivElement>
onMouseUpMouseEventHandler<HTMLDivElement>
onReleaseEventHandler<SyntheticEvent<HTMLDivElement, Event>>
Callback that's triggered after click i.e. mouseup and keyup of enter or space.
onTouchEndTouchEventHandler<HTMLDivElement>
onTouchStartTouchEventHandler<HTMLDivElement>
MentionCharCount
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
countPropsHTMLAttributes<HTMLDivElement>
getCharCount(value: EditorState) => number(editorState: EditorState) => { const mentionExtraCount = sum( convertToRaw(editorState.getCurrentContent()).blocks.map((b) => sum(b.entityRanges.map((er) => er.length - 1))) ); return getTextCharCount(editorState) - mentionExtraCount; }
outOfnumber
outOfPropsHTMLAttributes<HTMLDivElement>
MentionDisplay
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
editorPropsPluginEditorProps & { ref?: Ref<PluginEditor>; }
valueEditorState
MentionList
Prop nameTypeDefaultDescription
configMentionPluginConfig
idstring
initialIsOpenboolean
initialKeyboardHighlightedIndexnumber
initialMouseHighlightedIndexnumber
initialSearchValuestring
initialSelectedIndexnumber
initialValueSelectValue
isOpenboolean
keyboardHighlightedIndexnumber
listPropsSelectScrollerProps
mouseHighlightedIndexnumber
onChangeChangeCallback
Called when selected value is changed. Different from onSelect, onChange is not called when the value is already selected.
onIsOpenChange(isOpen: boolean) => void
onKeyboardHighlightedIndexChange(index: number) => void
onMouseHighlightedIndexChange(index: number) => void
onSearchSearchCallback
onSelectChangeCallback
Different from onChange: onSelect is triggered even if the option's value is the selected one.
onSelectedIndexChange(index: number) => void
renderButton(props: MentionButtonProps) => ReactElement<any, string | JSXElementConstructor<any>>(props: MentionButtonProps) => <MentionButton {...props} />
searchValuestring
This is not the selected value. Rather, it's a search value on input if you use SelectSearch.
selectedIndexnumber
stateReducerAcdcStateReducer
valueSelectValue
MentionOption
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
dataany
disabledboolean
indexnumber
leftElementReactNode
namestring
valueSelectValue
MentionPopover
    Example
    Example
    Basic Usage
    Basic Usage
    Serializing data
    Serializing data
    Customizing list
    Customizing list
    Addons
    Addons
    Resizing and placeholder
    Resizing and placeholder
    Trigger and other configs
    Trigger and other configs
    Caveats
    Caveats
    As a display
    As a display
    API
    API
    Mention
    Mention
    MentionButton
    MentionButton
    MentionCharCount
    MentionCharCount
    MentionDisplay
    MentionDisplay
    MentionList
    MentionList
    MentionOption
    MentionOption
    MentionPopover
    MentionPopover
Coral is a thoroughly developed design system widely adopted by developers and designers for creating beautiful and user-friendly Sea internal products.

Copyright © 2018-2025 Sea Labs