Skip to content
API 风格:

Mentions Mentions ​

LhMentions @ mentions: typing @ opens a member suggestion panel and inserts the mention into the text (email addresses are not triggered).

Basic Usage ​

Basic Usage
vue
<script setup lang="ts">
import { ref } from 'vue'
import { LhMentions } from '@lh-ui/vue3'

const text = ref('')
const members = [
  { label: 'Alice' },
  { label: 'Bob' },
  { label: 'Carol' },
]
const t1 = {
  placeholder: 'Type @ to mention a member',
}
</script>

<template>
<LhMentions v-model="text" :options="members" :placeholder="t1.placeholder" />
</template>
vue
<script>
import { LhMentions } from '@lh-ui/vue3'

export default {
  components: { LhMentions },
  data() {
    return {
      text: '',
      members: [
      { label: 'Alice' },
      { label: 'Bob' },
      { label: 'Carol' },
    ],
      t1: {
      placeholder: 'Type @ to mention a member',
    },
    }
  },
}
</script>

<template>
<LhMentions v-model="text" :options="members" :placeholder="t1.placeholder" />
</template>
Multiline
vue
<script setup lang="ts">
import { ref } from 'vue'
import { LhMentions } from '@lh-ui/vue3'

const text2 = ref('')
const t2 = {
  placeholder2: 'Multiline, type @ to mention',
}
</script>

<template>
<LhMentions v-model="text2" :options="members" multiline :placeholder="t2.placeholder2" />
</template>
vue
<script>
import { LhMentions } from '@lh-ui/vue3'

export default {
  components: { LhMentions },
  data() {
    return {
      text2: '',
      t2: {
      placeholder2: 'Multiline, type @ to mention',
    },
    }
  },
}
</script>

<template>
<LhMentions v-model="text2" :options="members" multiline :placeholder="t2.placeholder2" />
</template>

Mentions API ​

Props ​

NameDescriptionTypeDefault
modelValueText content (v-model)string''
optionsMember options[LhMentionOption](#type-LhMentionOption)[]() => []
prefixTrigger characterstring'@'
placeholderPlaceholderstring''
disabledDisabledbooleanfalse
multilineMultiline textarea (single-line input by default)booleanfalse
ariaLabelAccessibility namestring—
sxQuick layout propsLhSxProps—

Events ​

NameDescriptionType
update:modelValueFired when the text changes(value: string)
changeFired when the text changes(value: string)
selectFired when a member is mentioned(option: LhMentionOption)

Slots ​

NameDescription
emptyEmpty state when nothing matches

Accessibility ​

  • The input is a role="combobox" linked to the suggestion panel via aria-expanded / aria-controls / aria-activedescendant
  • Email-safe: @ preceded by an ASCII word character (as in a@b.com) does not trigger the panel

Type Definitions ​

The TypeScript type structures exported by this component (auto-extracted from packages/components/mentions/src/types.ts and @lh-ui/share/core/* sources; click each entry to expand; see the Props table above for attribute descriptions):

LhMentionsProps
ts
export interface LhMentionsProps {
  modelValue?: string
  options?: LhMentionOption[]
  prefix?: string
  placeholder?: string
  disabled?: boolean
  multiline?: boolean
  ariaLabel?: string
  sx?: LhSxProps
}

Beauty of tradition, foundation of code