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
| Name | Description | Type | Default |
|---|---|---|---|
| modelValue | Text content (v-model) | string | '' |
| options | Member options | [LhMentionOption](#type-LhMentionOption)[] | () => [] |
| prefix | Trigger character | string | '@' |
| placeholder | Placeholder | string | '' |
| disabled | Disabled | boolean | false |
| multiline | Multiline textarea (single-line input by default) | boolean | false |
| ariaLabel | Accessibility name | string | — |
| sx | Quick layout props | LhSxProps | — |
Events
| Name | Description | Type |
|---|---|---|
| update:modelValue | Fired when the text changes | (value: string) |
| change | Fired when the text changes | (value: string) |
| select | Fired when a member is mentioned | (option: LhMentionOption) |
Slots
| Name | Description |
|---|---|
| empty | Empty state when nothing matches |
Accessibility
- The input is a
role="combobox"linked to the suggestion panel viaaria-expanded/aria-controls/aria-activedescendant - Email-safe:
@preceded by an ASCII word character (as ina@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
}
