Message
Preview

Message shells, response rendering, markdown, attachments, and actions.

Overview

Message provides layout and visual treatment for user and assistant messages. It does not own message records, streaming state, or persistence.

Use MessageResponse for assistant-authored markdown. It wraps Streamdown, so normal markdown rendering works through the component without importing Streamdown at the call site.

Usage

import {
  Attachment,
  AttachmentPreview,
  Attachments,
  Message,
  MessageAction,
  MessageActions,
  MessageContent,
  MessageResponse,
  MessageToolbar,
} from "@tilt-legal/cubitt-components/chat-elements";

Examples

Default

Markdown

Attachments

API Reference

Message

Root message shell. Extends all HTML div props.

PropTypeDefaultDescription
from"system" | "user" | "assistant"-Message role. Required.
childrenReact.ReactNode-Message content, toolbar, branches, or actions.
classNamestring-Additional CSS classes for the message shell.

MessageContent

Styled message content container. Extends all HTML div props.

PropTypeDefaultDescription
childrenReact.ReactNode-Text, markdown response, or custom content.
classNamestring-Additional CSS classes for the content.

MessageResponse

Markdown response renderer powered by Streamdown. Extends Streamdown props.

PropTypeDefaultDescription
childrenReact.ReactNode-Markdown content to render.
classNamestring-Additional CSS classes for the Streamdown root.

MessageToolbar

Toolbar row for message actions or branch controls. Extends all HTML div props.

PropTypeDefaultDescription
childrenReact.ReactNode-Toolbar content.
classNamestring-Additional CSS classes for the toolbar.

MessageActions

Action group inside a toolbar. Extends all HTML div props.

PropTypeDefaultDescription
childrenReact.ReactNode-MessageAction buttons.
classNamestring-Additional CSS classes for the action group.

MessageAction

Icon action button with optional tooltip. Extends Button props.

PropTypeDefaultDescription
tooltipstring-Tooltip content. Also used as screen-reader text when label is omitted.
labelstring-Screen-reader text for the action.
variantButtonProps["variant"]"ghost"Button variant.
modeButtonProps["mode"]"icon"Button mode.
sizeButtonProps["size"]"sm"Button size.
childrenReact.ReactNode-Icon or custom action content.

MessageAttachment

Attachment convenience component for messages. Extends Attachment props except data, and requires chat attachment data.

PropTypeDefaultDescription
dataChatAttachmentFileData-File attachment data. Required.
onRemove() => void-Enables the built-in remove button.
aria-labelstringgenerated attachment labelAccessible label for the attachment.
titlestringgenerated attachment labelTitle attribute for the attachment.
classNamestring-Additional CSS classes for the attachment item.

MessageAttachments

Message attachment container. Extends Attachments props.

PropTypeDefaultDescription
variant"grid" | "inline" | "list""grid"Attachment layout variant.
childrenReact.ReactNode-Attachment items. Renders nothing when omitted.
classNamestring-Additional CSS classes for the attachment container.

MessageBranch

Stateful branch container for alternate message responses. Extends all HTML div props.

PropTypeDefaultDescription
defaultBranchnumber0Initial selected branch index.
onBranchChange(branchIndex: number) => void-Callback fired when previous/next changes branch.
childrenReact.ReactNode-Branch content and branch controls.
classNamestring-Additional CSS classes for the branch container.

MessageBranchContent

Branch content switcher. Each child is treated as one branch. Extends all HTML div props.

PropTypeDefaultDescription
childrenReact.ReactNode-Branch children to register and switch between.
classNamestring-Additional CSS classes for each branch wrapper.

MessageBranchSelector

Wrapper for branch navigation controls. Extends all HTML div props and renders nothing when there is only one branch.

PropTypeDefaultDescription
from"system" | "user" | "assistant"-Message role value. Required by the public prop type.
childrenReact.ReactNode-Previous/page/next branch controls.
classNamestring-Additional CSS classes for the selector wrapper.

MessageBranchPrevious

Previous branch button. Extends Button props and must be used inside MessageBranch.

PropTypeDefaultDescription
childrenReact.ReactNodeleft chevron iconCustom previous icon/content.
disabledbooleanderivedDisabled automatically when one branch exists.
classNamestring-Additional CSS classes for the button.

MessageBranchNext

Next branch button. Extends Button props and must be used inside MessageBranch.

PropTypeDefaultDescription
childrenReact.ReactNoderight chevron iconCustom next icon/content.
disabledbooleanderivedDisabled automatically when one branch exists.
classNamestring-Additional CSS classes for the button.

MessageBranchPage

Current branch page indicator. Extends all HTML span props.

PropTypeDefaultDescription
classNamestring-Additional CSS classes for the page label.

The rendered text is generated from the current branch and total branch count.

On this page