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

<mth-ai-message>

@methane-ui/ai~6.8 KB brotli (kit + Lit)~1.4 KB marginal

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

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

Properties & Attributes

PropertyAttributeTypeDefaultDescription
rolerole'user' | 'assistant' | 'system'"assistant"Sender role (user, assistant, or system).
contentcontentstring""Markdown text content rendered through @methane-ui/sanitize.
allowRawHtmlallow-raw-htmlbooleanfalseOpt-in raw HTML sanitization inside Markdown. Disabled (false) by default.
streamingstreamingbooleanfalseDisplays active streaming cursor indicator and live region updates.
authorauthorstring""Display author name overriding localized role label.
timestamptimestampstring""Optional formatted timestamp displayed in the header.
showActionsshow-actionsbooleantrueShows copy and regenerate action buttons.

Events

EventDetail TypeDescription
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

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusFocus ownership matches focusModel="none".lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
statesExposes ElementInternals CustomStateSet flags: :state(streaming), :state(copied).Conformance suite
i18nRoutes 8 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test