Skip to content
Browse docs and components

Chat Message

chat-message

One turn of an AI conversation: a compact bubble for the person, full-width prose for the assistant, a streaming caret, and copy, regenerate and feedback actions that keyboard and touch can always reach.

Responsive

Install

$npxshadcnadd@forme/chat-message

Adds the component, its registry dependencies, and the token stylesheet you import once.

Usage

import { ChatMessage } from "@/components/forme/chat-message/chat-message";

<ChatMessage from="user">Summarise this thread.</ChatMessage>
<ChatMessage from="assistant" name="Forme" copyText={answer} onRetry={retry}>
  {answer}
</ChatMessage>

When to use

Reach for it

  • Each turn of a conversation with an assistant: a compact bubble for the person, full-width prose for the reply.

Use something else

  • Chat between people, where both sides are equal; a symmetric message list reads better.

API reference

Read from the source, so it is the API of the file you install. A prop marked * is required.

ChatMessage

One turn of a conversation.

PropTypeDefaultDescription
from*"user" | "assistant"—
avatarReactNode—Shown beside an assistant message. An avatar, a logo.
namestring—Who is speaking, for screen readers and the visible name.
streamingboolean—Draws a caret after the content while a reply is still arriving.
copyTextstring—The plain text to copy. The copy action appears only when this is set.
onRetry() => void—
onFeedback(value: "up" | "down") => void—Called with the reader's verdict. The thumbs appear only when this is set.

Also takes every prop of <article> attributes.

Accessibility

  • Each turn is an <article> named by who said it.
  • The copy, retry and feedback actions are always present at low contrast, so touch and keyboard reach them without hover.
  • Copying and feedback are confirmed through a polite live region.

Motion

  • While streaming, a caret blinks after the content.