Back to Ant Design

Mentions

components/mentions/index.en-US.md

6.3.74.2 KB
Original Source

When To Use

When you need to mention someone or something.

Examples

<!-- prettier-ignore -->

<code src="./demo/basic.tsx">Basic</code> <code src="./demo/size.tsx" version="6.0.0">Size</code> <code src="./demo/variant.tsx">Variants</code> <code src="./demo/async.tsx">Asynchronous loading</code> <code src="./demo/form.tsx">With Form</code> <code src="./demo/prefix.tsx">Customize Trigger Token</code> <code src="./demo/readonly.tsx">disabled or readOnly</code> <code src="./demo/placement.tsx">Placement</code> <code src="./demo/allowClear.tsx">With clear icon</code> <code src="./demo/autoSize.tsx">autoSize</code> <code src="./demo/autosize-textarea-debug.tsx" debug>debug autoSize</code> <code src="./demo/status.tsx">Status</code> <code src="./demo/style-class.tsx" version="6.0.0">Custom semantic dom styling</code> <code src="./demo/render-panel.tsx" debug>_InternalPanelDoNotUseOrYouWillBeFired</code> <code src="./demo/component-token.tsx" debug>Component Token</code>

API

Common props ref:Common props

Mention

PropertyDescriptionTypeDefaultVersion
allowClearIf allow to remove mentions content with clear iconboolean | { clearIcon?: ReactNode }false5.13.0
autoSizeTextarea height autosize feature, can be set to true | false or an object { minRows: 2, maxRows: 6 }boolean | objectfalse
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-
defaultValueDefault valuestring-
filterOptionCustomize filter option logicfalse | (input: string, option: OptionProps) => boolean-
getPopupContainerSet the mount HTML node for suggestions() => HTMLElement-
notFoundContentSet mentions content when not matchReactNodeNot Found
placementSet popup placementtop | bottombottom
prefixSet trigger prefix keywordstring | string[]@
splitSet split string before and after selected mentionstring
sizeThe size of the input boxlarge | medium | small-
statusSet validation status'error' | 'warning' | 'success' | 'validating'-4.19.0
validateSearchCustomize trigger search logic(text: string, props: MentionsProps) => void-
valueSet value of mentionsstring-
variantVariants of Inputoutlined | borderless | filled | underlinedoutlined5.13.0 | underlined: 5.24.0
onBlurTrigger when mentions lose focus() => void-
onChangeTrigger when value changed(text: string) => void-
onClearCallback when click the clear button() => void-5.20.0
onFocusTrigger when mentions get focus() => void-
onResizeThe callback function that is triggered when textarea resizefunction({ width, height })-
onSearchTrigger when prefix hit(text: string, prefix: string) => void-
onSelectTrigger when user select the option(option: OptionProps, prefix: string) => void-
onPopupScrollTrigger when mentions scroll(e: Event) => void-5.23.0
optionsOption ConfigurationOptions[]5.1.0
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-

Mention methods

NameDescription
blur()Remove focus
focus()Get focus

Option

<!-- prettier-ignore -->
PropertyDescriptionTypeDefault
labelTitle of the optionReact.ReactNode-
keyThe key value of the optionstring-
disabledOptionalboolean-
classNameclassNamestring-
styleThe style of the optionReact.CSSProperties-

Semantic DOM

<code src="./demo/_semantic.tsx" simplify="true"></code>

Design Token

<ComponentTokenTable component="Mentions"></ComponentTokenTable>