← All Components
<mth-message-composer>
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
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>import '@methane-ui/chat/message-composer';
import '@methane-ui/react';
export function Example() {
return <mth-message-composer submit-on-enter max-length="0"></mth-message-composer>;
}<script setup lang="ts">
import '@methane-ui/chat/message-composer';
</script>
<template>
<mth-message-composer submit-on-enter max-length="0"></mth-message-composer>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/chat/message-composer';
import { MthMessageComposerDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthMessageComposerDirective],
template: `<mth-message-composer submit-on-enter max-length="0"></mth-message-composer>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/chat/message-composer';
import MthMessageComposer from '@methane-ui/svelte/MthMessageComposer.svelte';
</script>
<MthMessageComposer submit-on-enter max-length="0"></MthMessageComposer>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
value | value | string | "" | Current message draft text. |
defaultValue | default-value | string | "" | Initial form reset value. |
name | name | string | "" | Form field submission name. |
label | label | string | "" | Accessible label for the composer. |
placeholder | placeholder | string | "" | Placeholder text shown inside empty textarea. |
hint | hint | string | "" | Helper guidance shown below the composer. |
error | error | string | "" | Custom validation error text. |
disabled | disabled | boolean | false | Disables editing and action buttons. |
required | required | boolean | false | Marks a non-empty message as required. |
streaming | streaming | boolean | false | Displays stop-generation button instead of send while streaming. |
submitOnEnter | submit-on-enter | boolean | true | Submits on bare Enter (Shift+Enter inserts newline). |
maxLength | max-length | number | 0 | Optional maximum character limit (0 for unlimited). |
Events
| Event | Detail Type | Description |
|---|---|---|
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-stop | undefined | Fired when the user cancels streaming generation. |
mth-attach | undefined | Fired when attachment trigger is pressed. |
mth-emoji | undefined | Fired when emoji trigger is pressed. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Enter | both | submitOnEnter is true and IME is not composing | submits message and emits mth-submit |
| Mod+Enter | both | textarea focused and IME is not composing | submits message and emits mth-submit |
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 2 APG keyboard transitions across LTR/RTL. | mth-message-composer.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(disabled), :state(streaming), :state(invalid). | Conformance suite |
| i18n | Routes 7 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |