← All Components
<mth-ai-message>
AI conversation message bubble with sanitized streaming Markdown rendering (ADR-012) and copy/regenerate actions.
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-ai-message>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ai/ai-message"></script>
<mth-ai-message role="user" show-actions>Example</mth-ai-message>import '@methane-ui/ai/ai-message';
import '@methane-ui/react';
export function Example() {
return <mth-ai-message role="user" show-actions>Example</mth-ai-message>;
}<script setup lang="ts">
import '@methane-ui/ai/ai-message';
</script>
<template>
<mth-ai-message role="user" show-actions>Example</mth-ai-message>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ai/ai-message';
import { MthAiMessageDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthAiMessageDirective],
template: `<mth-ai-message role="user" show-actions>Example</mth-ai-message>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ai/ai-message';
import MthAiMessage from '@methane-ui/svelte/MthAiMessage.svelte';
</script>
<MthAiMessage role="user" show-actions>Example</MthAiMessage>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
role | role | 'user' | 'assistant' | 'system' | "assistant" | Sender role (user, assistant, or system). |
content | content | string | "" | Markdown text content rendered through @methane-ui/sanitize. |
allowRawHtml | allow-raw-html | boolean | false | Opt-in raw HTML sanitization inside Markdown. Disabled (false) by default. |
streaming | streaming | boolean | false | Displays active streaming cursor indicator and live region updates. |
author | author | string | "" | Display author name overriding localized role label. |
timestamp | timestamp | string | "" | Optional formatted timestamp displayed in the header. |
showActions | show-actions | boolean | true | Shows copy and regenerate action buttons. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-copy | { content: string; ok: boolean } | Fired when the message content is copied via ClipboardAndShare. |
mth-regenerate | { content: string } | Fired when the user requests regenerating an assistant response. |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | Focus ownership matches focusModel="none". | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| states | Exposes ElementInternals CustomStateSet flags: :state(streaming), :state(copied). | Conformance suite |
| i18n | Routes 8 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |