Back to Element Plus

Mention

docs/en-US/component/mention.md

2.13.78.8 KB
Original Source

Mention

Used to mention someone or something in an input.

Basic Usage

The most basic usage.

:::demo

mention/basic

:::

Props ^(2.11.3)

You can customize the alias of the options through the props attribute.

:::demo

mention/props

:::

Textarea

The input type can be set to textarea.

:::demo

mention/textarea

:::

Customize label

Customize label by label slot.

:::demo

mention/label

:::

Load remote options

Load options asynchronously.

:::demo

mention/loading

:::

Customize trigger token

Customize trigger token by prefix props. Default to @, Array<string> also supported.

:::demo

mention/prefix

:::

Delete as a whole

Set the whole attribute to true, and when you press the backspace, the mention will be deleted as a whole. Set the check-is-whole attribute to customize the checking logic. :::demo

mention/whole

:::

Work with form

to work with el-form.

:::demo

mention/form

:::

::: tip Since this component is developed based on the component el-input , the original properties have not changed, so no repetition here, and please go to the original component to view the documentation. :::

API

Attributes

NameDescriptionTypeDefault
optionsmention options list^[array]MentionOption[][]
props ^(2.11.3)configuration options^[object]MentionOptionProps{value: 'value', label: 'label', disabled: 'disabled'}
prefixprefix character to trigger mentions. The string length must be exactly 1^[string] | ^[array]string[]'@'
splitcharacter to split mentions. The string length must be exactly 1^[string]' '
filter-optioncustomize filter option logic^[false] | ^[Function](pattern: string, option: MentionOption) => boolean
placementset popup placement^[string]'bottom' | 'top''bottom'
show-arrowwhether the dropdown panel has an arrow^[boolean]false
offsetoffset of the dropdown panel^[number]0
wholewhen backspace is pressed to delete, whether the mention content is deleted as a whole^[boolean]false
check-is-wholewhen backspace is pressed to delete, check if the mention is a whole^[Function](pattern: string, prefix: string) => boolean
loadingwhether the dropdown panel of mentions is in a loading state^[boolean]false
model-value / v-modelinput value^[string]
popper-classcustom class name for dropdown panel^[string] / ^[object]''
popper-style ^(2.11.5)custom style for dropdown panel^[string] / ^[object]
popper-optionspopper.js parameters^[object] refer to popper.js doc
input props

Events

NameDescriptionType
searchtrigger when prefix hit^[Function](pattern: string, prefix: string) => void
selecttrigger when user select the option^[Function](option: MentionOption, prefix: string) => void
whole-remove ^(2.10.4)trigger when a whole mention is removed and whole is true or check-is-whole is true^[Function](pattern: string, prefix: string) => void
input events

Slots

NameDescriptionType
labelcontent as option label^[object]{ item: MentionOption, index: number }
loadingcontent as option loading
headercontent at the top of the dropdown
footercontent at the bottom of the dropdown
input slots

Exposes

NameDescriptionType
inputel-input component instance^[object]Ref<InputInstance | null>
tooltipel-tooltip component instance^[object]Ref<TooltipInstance | null>
dropdownVisible ^(2.8.5)tooltip display status^[object]ComputedRef<boolean>

Type Declarations

<details> <summary>Show declarations</summary>
ts
type MentionOption = {
  value?: string
  label?: string
  disabled?: boolean
  [key: string]: any
}

type MentionOptionProps = {
  value?: string
  label?: string
  disabled?: string
  [key: string]: string | undefined
}
</details>