← All Components
<mth-prompt-input>
IME-safe auto-sizing AI prompt composer with FormControlController integration, Enter/Mod+Enter submission, and stop-generation 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-prompt-input>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ai/prompt-input"></script>
<mth-prompt-input submit-on-enter max-rows="6"></mth-prompt-input>import '@methane-ui/ai/prompt-input';
import '@methane-ui/react';
export function Example() {
return <mth-prompt-input submit-on-enter max-rows="6"></mth-prompt-input>;
}<script setup lang="ts">
import '@methane-ui/ai/prompt-input';
</script>
<template>
<mth-prompt-input submit-on-enter max-rows="6"></mth-prompt-input>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ai/prompt-input';
import { MthPromptInputDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthPromptInputDirective],
template: `<mth-prompt-input submit-on-enter max-rows="6"></mth-prompt-input>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ai/prompt-input';
import MthPromptInput from '@methane-ui/svelte/MthPromptInput.svelte';
</script>
<MthPromptInput submit-on-enter max-rows="6"></MthPromptInput>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
value | value | string | "" | Current prompt text value. |
name | name | string | "" | Form field name submitted via ElementInternals. |
label | label | string | "" | Accessible field label. |
placeholder | placeholder | string | "" | Textarea placeholder text. |
hint | hint | string | "" | Optional helper text displayed below the composer. |
error | error | string | "" | Explicit error text displayed when invalid. |
disabled | disabled | boolean | false | Disables prompt input and submission. |
required | required | boolean | false | Marks the prompt as required for form validation. |
streaming | streaming | boolean | false | Switches the primary control into stop-generation mode. |
submitOnEnter | submit-on-enter | boolean | true | When true, Enter submits and Shift+Enter adds a newline; when false, Mod+Enter submits. |
maxRows | max-rows | number | 6 | Maximum visible auto-sized row count. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-input | { value: string } | Fired as the user types prompt text (after IME composition ends). |
mth-change | { value: string } | Fired when the prompt input commits on blur/change. |
mth-submit | { value: string } | Cancelable event fired when submitting the prompt. |
mth-stop | void | Fired when the user activates the stop-generation button. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Enter | both | focused and submitOnEnter is true without Shift or IME composition | emits cancelable mth-submit with current value |
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 1 APG keyboard transitions across LTR/RTL. | mth-prompt-input.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(disabled), :state(streaming), :state(invalid), :state(dirty), :state(touched), :state(empty). | Conformance suite |
| i18n | Routes 7 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |