- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Command
- Context Menu
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Input Group
- Kbd
- Label
- Menu
- Menubar
- Message
- Meter
- Number Field
- OTP Field
- Pagination
- Popover
- Preview Card
- Progress
- Questionnaire
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Toolbar
- Tooltip
- Artifact
- Audio Player
- Canvas
- Chain of Thought
- Checkpoint
- Code Block
- Commit
- Connection
- Context
- Controls
- Edge
- Environment Variables
- Mic Selector
- Model Selector
- Node
- Node Toolbar
- Open in Chat
- Panel
- Plan
- Prompt Input
- Queue
- Reasoning
- Sandbox
- Schema Display
- Shimmer
- Snippet
- Sources
- Speech Input
- Stack Trace
- Suggestion
- Tool
- Transcription
- Web Preview
Message
Lays out one conversation turn with its content, actions and branches.
items-center justify-center.import { CopyIcon, RefreshCcwIcon } from "lucide-react";
import {
Message,
MessageAction,
MessageActions,
MessageContent,
MessageToolbar,
} from "@/components/ui/message";
export default function Particle() {
return (
<div className="flex w-full max-w-md flex-col gap-4">
<Message from="user">
<MessageContent>How do I center a div?</MessageContent>
</Message>
<Message from="assistant">
<MessageContent>
Wrap it in a flex container and use <code>items-center justify-center</code>.
</MessageContent>
<MessageToolbar>
<MessageActions>
<MessageAction tooltip="Copy">
<CopyIcon aria-hidden="true" />
</MessageAction>
<MessageAction tooltip="Retry">
<RefreshCcwIcon aria-hidden="true" />
</MessageAction>
</MessageActions>
</MessageToolbar>
</Message>
</div>
);
}
Installation
pnpm dlx shadcn@latest add @frontal-labs/message
Usage
import {
Message,
MessageAction,
MessageActions,
MessageContent,
MessageResponse,
MessageToolbar,
} from "@/components/ui/message";Each turn is a Message with its from role. MessageContent holds the turn's
content and applies the bubble treatment for user turns:
<Message from="user">
<MessageContent>How do I center a div?</MessageContent>
</Message>
<Message from="assistant">
<MessageContent>
<MessageResponse>{markdown}</MessageResponse>
</MessageContent>
</Message>API Reference
Message
A single conversation turn. Stacks its children vertically and aligns the turn to the end of the row for the user.
| Prop | Type | Description |
|---|---|---|
from | UIMessage["role"] | The role of the turn. "user" aligns the turn to the end. |
MessageContent
Wraps the content of the turn. Renders as a bubble inside a "user" message and
as plain text inside an "assistant" message.
MessageResponse
Renders streamed markdown with Streamdown, including code
and CJK plugins. Memoized on its children, so it only re-renders when the text
changes.
MessageToolbar
A full-width row below the content, typically holding MessageActions and a
branch selector.
MessageActions
Groups action buttons together in a row.
MessageAction
An icon button for a single action. Wraps Button and
adds a tooltip when tooltip is set.
| Prop | Type | Default | Description |
|---|---|---|---|
tooltip | string | - | Tooltip text. Also used as the accessible name. |
label | string | - | Accessible name, takes precedence over tooltip. |
variant | Button["variant"] | "ghost" | Button variant. |
size | Button["size"] | "icon-sm" | Button size. |
MessageBranch
Provides the branch context for a turn that has several regenerated variants.
| Prop | Type | Default | Description |
|---|---|---|---|
defaultBranch | number | 0 | Index of the branch shown first. |
onBranchChange | (branchIndex: number) => void | - | Called when the visible branch changes. |
MessageBranchContent
Holds one child per branch and renders only the current one.
MessageBranchSelector
The control row for switching branches. Renders nothing when there is only one branch.
| Prop | Type | Description |
|---|---|---|
from | UIMessage["role"] | The role of the turn it belongs to. |
MessageBranchPrevious
Button that moves to the previous branch, wrapping around at the start.
MessageBranchNext
Button that moves to the next branch, wrapping around at the end.
MessageBranchPage
Shows the current position as 1 of 3.
Examples
With Actions
<Message from="assistant">
<MessageContent>
<MessageResponse>{markdown}</MessageResponse>
</MessageContent>
<MessageToolbar>
<MessageActions>
<MessageAction tooltip="Copy">
<CopyIcon aria-hidden="true" />
</MessageAction>
<MessageAction tooltip="Retry">
<RefreshCcwIcon aria-hidden="true" />
</MessageAction>
</MessageActions>
</MessageToolbar>
</Message>With Branches
<MessageBranch defaultBranch={0}>
<MessageBranchContent>
<Message from="assistant">
<MessageContent>The first answer.</MessageContent>
</Message>
<Message from="assistant">
<MessageContent>The second answer.</MessageContent>
</Message>
</MessageBranchContent>
<MessageBranchSelector from="assistant">
<MessageBranchPrevious />
<MessageBranchPage />
<MessageBranchNext />
</MessageBranchSelector>
</MessageBranch>