Methane@methane-ui/*
CSS LayoutsComponentsSkillsTheme BuilderGitHub
← All Components

<mth-mention-input>

@methane-ui/ui~12.3 KB brotli (cold + Lit)~4.4 KB marginal

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

Interactive StageLive Custom Element · <mth-mention-input> (@methane-ui/ui)
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>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
namenamestring""Form field name submitted with FormData.
valuevaluestring""Current text content including inserted mention tokens.
defaultValuedefault-valuestring""Initial text value used when resetting the form.
triggertriggerstring"@"Prefix character that activates the mention suggestions popup.
options—ReadonlyArray<unknown> | nullnullList of MentionOption candidates available for autocomplete.
labellabelstring""Accessible field label.
placeholderplaceholderstring""Input placeholder text.
hinthintstring""Helper text displayed below the control.
errorerrorstring""Explicit error message displayed below the control.
multilinemultilinebooleanfalseRenders a textarea instead of a single-line input.
rowsrowsnumber3Number of visible text lines when multiline is enabled.
openopenbooleanfalseControls whether the mention suggestions popup is open.
disableddisabledbooleanfalseDisables editing and form submission.
readOnlyreadonlybooleanfalsePrevents editing while keeping text readable and focusable.
requiredrequiredbooleanfalseMarks input text as required for form validation.

Events

EventDetail TypeDescription
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-openundefinedCancelable event fired before opening suggestions.
mth-after-openundefinedFired after suggestions open.
mth-closeundefinedCancelable event fired before closing suggestions.
mth-after-closeundefinedFired after suggestions close.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
ArrowDown / ArrowUpbothsuggestions opennavigates active mention option
Enterbothsuggestions open and option activeinserts selected mention token
Escapebothsuggestions opencloses suggestions popup and restores focus

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusdelegatesFocus: true with zero host internals.role (ADR-014).lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
keyboardImplements all 3 APG keyboard transitions across LTR/RTL.mth-mention-input.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(dirty), :state(touched), :state(user-invalid), :state(disabled), :state(readonly), :state(required).Conformance suite
i18nRoutes 4 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test