Interface de chat com IA: respostas em streaming com cursor, estado “pensando” com brilho, renderização segura de Markdown (listas, negrito, código com botão de copiar), editor de mensagens que cresce sozinho com anexos, seletor de modelo, sugestões, parar / regenerar e rolagem automática que cede ao usuário.
Agente de IA com o servidor MCP do Marvelous UI: install_components({ slugs: ["ai-chat"], target_dir: "<absolute path>/src/marvelous", framework: "react" }).
Response source. Default: local simulation (canned English replies, no network). Honor signal for stopping.
messages
{ role, content, files? }[]
Reads/writes the history. Also settable via a child <script type="application/json">.
busy
boolean
Read-only: a response is in progress.
strings
Partial<Record<string, string>>
Overrides for the default text (en-US): conversation (log label, {label} placeholder), jumpToLatest (jump button), send / sendTitle and stop / stopTitle (send button label and tooltip), attachments (attachment list label), removeFile (chip remove button, {name}), sizeBytes / sizeKB / sizeMB (file size, {n}), code (caption of a fence without a language), copyCode, copyResponse, responseActions (action bar label), regenerate / regenerateTitle (regenerate button label and tooltip), stopped (stopped notice, also announced), error (reply shown when the responder fails), announceWriting ({label}), announceResponse ({label}, {text}), codeBlock (stands for code in that announcement), announceCopied. App-wide translations: setStrings() from core/i18n.js, under the key "ai-chat". Can be set before the element is defined.
Methods
Name
Descrição
send(text)
Sends a message (with pending attachments) and generates the response.
stop()
Stops generating (also Escape in the field, or the send button while it reads Stop).
Export: lightweight, safe Markdown rendering (textContent only). partial: the source may end mid-token (streaming or stopped), so a dangling ** or backtick closes or hides and an open fence stays a code block. The chat uses it while streaming and for a stopped reply.
Events
Name
Descrição
mv-send
Cancelable. detail: { content, files }.
mv-response
Response finished. detail: { content, stopped }.
mv-stop / mv-reset / mv-error
Stop, reset, responder error (detail.error).
Content structure
Name
Descrição
.mv-ai-chat-header
Free-form header; [data-ai-chat-model-label] shows the selected model, [data-ai-chat-reset] clears the conversation.
.mv-ai-chat-empty
Empty state (hidden after the first message); any [data-prompt] sends its text.
form.mv-ai-chat-composer
Composer: textarea (Enter sends, Shift + Enter = new line), input[type=file], ul.mv-ai-chat-attachments, [data-ai-chat-send] button with two icons (send / stop).
Attachment, file button, hint, model trigger and model description.
CSS variables
Name
Padrão
Descrição
--mv-ai-chat-max-width
46rem
Reading width of the thread and composer.
--mv-ai-chat-user-bg
Background of the user’s bubbles.
Accessibility
Thread with role=log (aria-busy while generating); each message is a named <article> (“You” / assistant name). Streaming isn’t read word by word: a role=status region announces “… is writing a reply”, then the final response (code is summarized). Send button: label toggles between Send / Stop. Focusable code blocks (horizontal scrolling by keyboard), named Copy / Regenerate buttons. Reduced motion: no typing animation or blinking caret.