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

<mth-message-composer>

@methane-ui/chat~9.0 KB brotli (kit + Lit)~2.6 KB marginal

Form-associated IME-safe chat message composer with Enter / Mod+Enter submit, attachment and emoji triggers, and streaming stop state.

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-message-composer> (@methane-ui/chat)
Ready · interact with <mth-message-composer>, or toggle Theme, Direction (LTR/RTL), or props above.

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/chat/message-composer"></script>
<mth-message-composer submit-on-enter max-length="0"></mth-message-composer>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
valuevaluestring""Current message draft text.
defaultValuedefault-valuestring""Initial form reset value.
namenamestring""Form field submission name.
labellabelstring""Accessible label for the composer.
placeholderplaceholderstring""Placeholder text shown inside empty textarea.
hinthintstring""Helper guidance shown below the composer.
errorerrorstring""Custom validation error text.
disableddisabledbooleanfalseDisables editing and action buttons.
requiredrequiredbooleanfalseMarks a non-empty message as required.
streamingstreamingbooleanfalseDisplays stop-generation button instead of send while streaming.
submitOnEntersubmit-on-enterbooleantrueSubmits on bare Enter (Shift+Enter inserts newline).
maxLengthmax-lengthnumber0Optional maximum character limit (0 for unlimited).

Events

EventDetail TypeDescription
mth-input{ value: string }Fired as draft text changes.
mth-change{ value: string }Fired when draft commits on blur.
mth-submit{ value: string }Cancelable event fired when user submits a non-empty message.
mth-stopundefinedFired when the user cancels streaming generation.
mth-attachundefinedFired when attachment trigger is pressed.
mth-emojiundefinedFired when emoji trigger is pressed.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
EnterbothsubmitOnEnter is true and IME is not composingsubmits message and emits mth-submit
Mod+Enterbothtextarea focused and IME is not composingsubmits message and emits mth-submit

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 2 APG keyboard transitions across LTR/RTL.mth-message-composer.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(disabled), :state(streaming), :state(invalid).Conformance suite
i18nRoutes 7 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test