← All Components
<mth-mention-input>
Form-associated single or multiline text input with trigger-character mention autocomplete popover.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-mention-input>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/mention-input"></script>
<mth-mention-input trigger="@" rows="3"></mth-mention-input>import '@methane-ui/ui/mention-input';
import '@methane-ui/react';
export function Example() {
return <mth-mention-input trigger="@" rows="3"></mth-mention-input>;
}<script setup lang="ts">
import '@methane-ui/ui/mention-input';
</script>
<template>
<mth-mention-input trigger="@" rows="3"></mth-mention-input>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/mention-input';
import { MthMentionInputDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthMentionInputDirective],
template: `<mth-mention-input trigger="@" rows="3"></mth-mention-input>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/mention-input';
import MthMentionInput from '@methane-ui/svelte/MthMentionInput.svelte';
</script>
<MthMentionInput trigger="@" rows="3"></MthMentionInput>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
name | name | string | "" | Form field name submitted with FormData. |
value | value | string | "" | Current text content including inserted mention tokens. |
defaultValue | default-value | string | "" | Initial text value used when resetting the form. |
trigger | trigger | string | "@" | Prefix character that activates the mention suggestions popup. |
options | — | ReadonlyArray<unknown> | null | null | List of MentionOption candidates available for autocomplete. |
label | label | string | "" | Accessible field label. |
placeholder | placeholder | string | "" | Input placeholder text. |
hint | hint | string | "" | Helper text displayed below the control. |
error | error | string | "" | Explicit error message displayed below the control. |
multiline | multiline | boolean | false | Renders a textarea instead of a single-line input. |
rows | rows | number | 3 | Number of visible text lines when multiline is enabled. |
open | open | boolean | false | Controls whether the mention suggestions popup is open. |
disabled | disabled | boolean | false | Disables editing and form submission. |
readOnly | readonly | boolean | false | Prevents editing while keeping text readable and focusable. |
required | required | boolean | false | Marks input text as required for form validation. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-change | { value: string; mentions: ReadonlyArray<string> } | Fired when input value or extracted mentions change. |
mth-mention-select | { option: unknown; trigger: string; value: string } | Fired when a mention suggestion is inserted. |
mth-open | undefined | Cancelable event fired before opening suggestions. |
mth-after-open | undefined | Fired after suggestions open. |
mth-close | undefined | Cancelable event fired before closing suggestions. |
mth-after-close | undefined | Fired after suggestions close. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| ArrowDown / ArrowUp | both | suggestions open | navigates active mention option |
| Enter | both | suggestions open and option active | inserts selected mention token |
| Escape | both | suggestions open | closes suggestions popup and restores focus |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 3 APG keyboard transitions across LTR/RTL. | mth-mention-input.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(dirty), :state(touched), :state(user-invalid), :state(disabled), :state(readonly), :state(required). | Conformance suite |
| i18n | Routes 4 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |