import { Message, MessageBubble, MessageContent } from "@/components/ui/message";
export default function MessageConversation() { return ( <div className="flex w-full max-w-md flex-col gap-4"> <Message align="end"> <MessageContent> <MessageBubble>How do I point www.example.com at my site?</MessageBubble> </MessageContent> </Message> <Message> <MessageContent> <MessageBubble variant="ghost"> Add the domain under Settings → Domains, then create a CNAME record at your DNS provider that points www.example.com to cname.example.net. </MessageBubble> </MessageContent> </Message> <Message align="end"> <MessageContent> <MessageBubble>How long does it take to verify?</MessageBubble> </MessageContent> </Message> <Message> <MessageContent> <MessageBubble variant="ghost"> Usually a few minutes, though some DNS providers take up to an hour. </MessageBubble> </MessageContent> </Message> </div> );}- Completed:Add the registryOnce per project
pnpm dlx shadcn@latest registry add @jarvis=https://ui.jarv.is/r/{name}.json - Completed:Add message
pnpm dlx shadcn@latest add @jarvis/message
Usage
import { Message, MessageBubble, MessageContent } from "@/components/ui/message";
export function Exchange() { return ( <> <Message align="end"> <MessageContent> <MessageBubble>When does my plan renew?</MessageBubble> </MessageContent> </Message> <Message> <MessageContent> <MessageBubble variant="ghost">Your plan renews on April 1.</MessageBubble> </MessageContent> </Message> </> );}align="end" places a message on the opposite side, for the person's own messages. A bubble is as
wide as its text, up to 80% of the message's width. A ghost bubble fills the full width. Long
words and links wrap inside the bubble.
MessageBubble preserves the line breaks in its text, so a message shows as the person typed it.
Render an assistant's reply with Markdown in place of the bubble. Markdown
fills the message's width, as a Trace or Tool does.
Composition
Examples
Variants
import { Message, MessageBubble, MessageContent } from "@/components/ui/message";
export default function MessageVariants() { return ( <div className="flex w-full max-w-md flex-col gap-3"> <Message> <MessageContent> <MessageBubble>Default, for most messages.</MessageBubble> </MessageContent> </Message> <Message align="end"> <MessageContent> <MessageBubble variant="primary">Primary, to set your own apart.</MessageBubble> </MessageContent> </Message> <Message> <MessageContent> <MessageBubble variant="outline">Outline, for quieter asides.</MessageBubble> </MessageContent> </Message> <Message> <MessageContent> <MessageBubble variant="destructive"> Destructive, for a message that failed. </MessageBubble> </MessageContent> </Message> <Message> <MessageContent> <MessageBubble variant="ghost"> Ghost has no frame and fills the width, for an assistant’s replies. </MessageBubble> </MessageContent> </Message> </div> );}With an avatar
MessageAvatar holds an Avatar and centers it on the message's first line,
however long the message runs. That's the MessageHeader, which names the sender above the bubble,
or else the first line of the bubble or reply.
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";import { Message, MessageAvatar, MessageBubble, MessageContent, MessageHeader,} from "@/components/ui/message";
const [tony, ada] = people;
export default function MessageWithAvatar() { return ( <div className="flex w-full max-w-md flex-col gap-4"> <Message> <MessageAvatar> <Avatar> <AvatarImage src={ada.image} alt="" /> <AvatarFallback>{ada.initials}</AvatarFallback> </Avatar> </MessageAvatar> <MessageContent> <MessageHeader> <span className="font-medium text-foreground">{ada.name}</span> <time dateTime="2026-03-04T09:41">9:41 AM</time> </MessageHeader> <MessageBubble>The staging deploy is green. Want me to promote it?</MessageBubble> </MessageContent> </Message> <Message align="end"> <MessageAvatar> <Avatar> <AvatarImage src={tony.image} alt="" /> <AvatarFallback>{tony.initials}</AvatarFallback> </Avatar> </MessageAvatar> <MessageContent> <MessageHeader> <span className="font-medium text-foreground">{tony.name}</span> <time dateTime="2026-03-04T09:42">9:42 AM</time> </MessageHeader> <MessageBubble variant="primary">Yes, ship it.</MessageBubble> </MessageContent> </Message> </div> );}Grouped
MessageGroup brings one sender's messages closer together. Put the avatar on the last message, and
give the others an empty MessageAvatar so their bubbles line up with it.
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";import { Message, MessageAvatar, MessageBubble, MessageContent, MessageGroup, MessageHeader,} from "@/components/ui/message";
const sam = people[2];
export default function MessageGrouped() { return ( <MessageGroup className="max-w-md"> <Message> <MessageAvatar /> <MessageContent> <MessageHeader> <span className="font-medium text-foreground">{sam.name}</span> </MessageHeader> <MessageBubble>Quick update on the launch.</MessageBubble> </MessageContent> </Message> <Message> <MessageAvatar /> <MessageContent> <MessageBubble>The docs are live and the changelog goes out at noon.</MessageBubble> </MessageContent> </Message> <Message> <MessageAvatar> <Avatar> <AvatarImage src={sam.image} alt="" /> <AvatarFallback>{sam.initials}</AvatarFallback> </Avatar> </MessageAvatar> <MessageContent> <MessageBubble>Shout if anything looks off.</MessageBubble> </MessageContent> </Message> </MessageGroup> );}With actions
MessageFooter holds actions such as a Copy Button. ghost buttons in
the footer render their icons in the muted icon color, and an xs or icon-xs button at the edge
aligns its icon with the edge of the message. Give icon-only actions an aria-label. To keep an
action pending while it runs, return a promise from its onClick.
import { RefreshCwIcon } from "lucide-react";
import { Button } from "@/components/ui/button";import { CopyButton } from "@/components/ui/copy-button";import { Message, MessageBubble, MessageContent, MessageFooter } from "@/components/ui/message";
const reply = "Add the domain under Settings → Domains, then create a CNAME record at your DNS provider that points www.example.com to cname.example.net. Verification usually finishes within a few minutes.";
async function regenerate() { await new Promise((resolve) => setTimeout(resolve, 1500));}
export default function MessageWithActions() { return ( <div className="flex w-full max-w-md flex-col gap-4"> <Message align="end"> <MessageContent> <MessageBubble>How do I point www.example.com at my site?</MessageBubble> </MessageContent> </Message> <Message> <MessageContent> <MessageBubble variant="ghost">{reply}</MessageBubble> <MessageFooter> <CopyButton value={reply} size="icon-xs" aria-label="Copy message" /> <Button variant="ghost" size="icon-xs" aria-label="Regenerate" onClick={regenerate}> <RefreshCwIcon /> </Button> </MessageFooter> </MessageContent> </Message> </div> );}Failed
When a reply fails, say so in a destructive bubble with role="alert", so screen readers announce
it, and offer a way to try again in its footer.
import { RefreshCwIcon } from "lucide-react";
import { Button } from "@/components/ui/button";import { Message, MessageBubble, MessageContent, MessageFooter } from "@/components/ui/message";
async function retry() { await new Promise((resolve) => setTimeout(resolve, 1500));}
export default function MessageFailed() { return ( <div className="flex w-full max-w-md flex-col gap-4"> <Message align="end"> <MessageContent> <MessageBubble>Summarize this week’s incidents.</MessageBubble> </MessageContent> </Message> <Message> <MessageContent> <MessageBubble variant="destructive" role="alert"> The reply couldn’t be finished. Check your connection and try again. </MessageBubble> <MessageFooter> <Button variant="ghost" size="xs" onClick={retry}> <RefreshCwIcon /> Retry </Button> </MessageFooter> </MessageContent> </Message> </div> );}With a trace
An assistant's message can show the steps it took with a Trace above its reply.
import { GlobeIcon, SearchIcon } from "lucide-react";
import { Message, MessageBubble, MessageContent } from "@/components/ui/message";import { Trace, TraceDescription, TraceIcon, TraceLine, TraceTitle } from "@/components/ui/trace";
export default function MessageWithTrace() { return ( <div className="flex w-full max-w-md flex-col gap-4"> <Message align="end"> <MessageContent> <MessageBubble>Is example.com’s certificate about to expire?</MessageBubble> </MessageContent> </Message> <Message> <MessageContent className="gap-3"> <Trace> <TraceLine> <TraceIcon> <SearchIcon /> </TraceIcon> <TraceTitle>Looked up example.com’s certificate</TraceTitle> <TraceDescription>0.4s</TraceDescription> </TraceLine> <TraceLine> <TraceIcon> <GlobeIcon /> </TraceIcon> <TraceTitle>Checked the certificate chain</TraceTitle> </TraceLine> </Trace> <MessageBubble variant="ghost"> No. It was renewed on March 2 and is valid until June 1, so there’s nearly three months left. Renewal is automatic. </MessageBubble> </MessageContent> </Message> </div> );}Props
| Part | Extends |
|---|---|
| MessageGroup | <div> |
| Message | <div> |
| MessageAvatar | <div> |
| MessageContent | <div> |
| MessageHeader | <div> |
| MessageBubble | <div> |
| MessageFooter | <div> |
Base UI's styling (opens in a new tab) and composition (opens in a new tab) guides say more about className, style and render.
MessageGroup
| Prop | Type | Default |
|---|---|---|
classNameCSS class applied to the element. | string | — |
styleStyle applied to the element. | React.CSSProperties | — |
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a | ComponentRenderFn<HTMLProps, {}> | React.ReactElement | — |
Message
| Prop | Type | Default |
|---|---|---|
alignWhich side of the conversation the message sits on: | "end" | "start" | "start" |
classNameCSS class applied to the element. | string | — |
styleStyle applied to the element. | React.CSSProperties | — |
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a | ComponentRenderFn<HTMLProps, {}> | React.ReactElement | — |
MessageAvatar
| Prop | Type | Default |
|---|---|---|
classNameCSS class applied to the element. | string | — |
styleStyle applied to the element. | React.CSSProperties | — |
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a | ComponentRenderFn<HTMLProps, {}> | React.ReactElement | — |
MessageContent
| Prop | Type | Default |
|---|---|---|
classNameCSS class applied to the element. | string | — |
styleStyle applied to the element. | React.CSSProperties | — |
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a | ComponentRenderFn<HTMLProps, {}> | React.ReactElement | — |
MessageHeader
| Prop | Type | Default |
|---|---|---|
classNameCSS class applied to the element. | string | — |
styleStyle applied to the element. | React.CSSProperties | — |
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a | ComponentRenderFn<HTMLProps, {}> | React.ReactElement | — |
MessageBubble
| Prop | Type | Default |
|---|---|---|
variant | "default" | "destructive" | "ghost" | "outline" | "primary" | "default" |
classNameCSS class applied to the element. | string | — |
styleStyle applied to the element. | React.CSSProperties | — |
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a | ComponentRenderFn<HTMLProps, {}> | React.ReactElement | — |
MessageFooter
| Prop | Type | Default |
|---|---|---|
classNameCSS class applied to the element. | string | — |
styleStyle applied to the element. | React.CSSProperties | — |
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a | ComponentRenderFn<HTMLProps, {}> | React.ReactElement | — |