ZaidanHomeDocsComponentsBlocksChartsTypesetCreate

Command Palette

Search for a command to run...

GitHub
New
Sections
  • Introduction
  • Components
  • Blocks
  • Installation
  • Customization
  • Dark Mode
  • Typeset
  • Zaidan Skills
  • FAQ
  • Roadmap
  • Changelog
Installation
  • Astro
  • Manual
  • Solid Start
  • TanStack Router
  • TanStack Start
  • Vite
Blocks
  • Data Grid
  • Event Calendar
  • Filters
  • Gantt
  • Image Crop
  • Kanban
  • Message Scroller
  • Questionnaire
  • Sortable
Components
  • Accordion
  • Alert
  • Alert Dialog
  • Aspect Ratio
  • Attachment
  • Avatar
  • Badge
  • Breadcrumb
  • Bubble
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Collapsible
  • Combobox
  • Command
  • Context Menu
  • Dialog
  • Drawer
  • Dropdown Menu
  • Empty
  • Field
  • Hover Card
  • Input
  • Input Group
  • Input OTP
  • Item
  • Kbd
  • Label
  • Marker
  • Menubar
  • Message
  • Native Select
  • Navigation Menu
  • Pagination
  • Popover
  • Progress
  • Radio Group
  • Resizable
  • Scroll Area
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Skeleton
  • Slider
  • Spinner
  • Switch
  • Table
  • Tabs
  • Textarea
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip

Message

Displays a message in a conversation, with optional avatar, header, footer, and alignment.

ME
Deploying to prod real quick.
R
It's 4:55 PM. On a Friday.
ME
It's a one-line change.
Delivered
R
It's always a one-line change 😭.
Alright, let me take a look.
👍
Oliver is typing...
1
import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar";
2
import { Bubble, BubbleContent, BubbleGroup, BubbleReactions } from "~/components/ui/bubble";
3
import { Marker, MarkerContent } from "~/components/ui/marker";
4
import {
5
Message,
6
MessageAvatar,
7
MessageContent,
8
MessageFooter,
9
} from "~/components/ui/message";
10
11
export default function MessageDemo() {
12
return (
13
<div class="flex w-full max-w-sm flex-col gap-6 py-12">
14
<Message align="end">
15
<MessageAvatar>
16
<Avatar>
17
<AvatarImage src="https://github.com/shadcn.png" alt="@me" />
18
<AvatarFallback>ME</AvatarFallback>
19
</Avatar>
20
</MessageAvatar>
21
<MessageContent>
22
<Bubble>
23
<BubbleContent>Deploying to prod real quick.</BubbleContent>
24
</Bubble>
25
</MessageContent>
26
</Message>
27
<Message>
28
<MessageAvatar>
29
<Avatar>
30
<AvatarImage src="https://github.com/evilrabbit.png" alt="@rabbit" />
31
<AvatarFallback>R</AvatarFallback>
32
</Avatar>
33
</MessageAvatar>
34
<MessageContent>
35
<Bubble variant="muted">
36
<BubbleContent>It's 4:55 PM. On a Friday.</BubbleContent>
37
</Bubble>
38
</MessageContent>
39
</Message>
40
<Message align="end">
41
<MessageAvatar>
42
<Avatar>
43
<AvatarImage src="https://github.com/shadcn.png" alt="@me" />
44
<AvatarFallback>ME</AvatarFallback>
45
</Avatar>
46
</MessageAvatar>
47
<MessageContent>
48
<Bubble>
49
<BubbleContent>It's a one-line change.</BubbleContent>
50
</Bubble>
51
<MessageFooter>Delivered</MessageFooter>
52
</MessageContent>
53
</Message>
54
<Message>
55
<MessageAvatar>
56
<Avatar>
57
<AvatarImage src="https://github.com/evilrabbit.png" alt="@rabbit" />
58
<AvatarFallback>R</AvatarFallback>
59
</Avatar>
60
</MessageAvatar>
61
<MessageContent>
62
<BubbleGroup>
63
<Bubble variant="muted">
64
<BubbleContent>It's always a one-line change 😭.</BubbleContent>
65
</Bubble>
66
<Bubble variant="muted">
67
<BubbleContent>Alright, let me take a look.</BubbleContent>
68
<BubbleReactions aria-label="Reactions: thumbs up">
69
<span>👍</span>
70
</BubbleReactions>
71
</Bubble>
72
</BubbleGroup>
73
</MessageContent>
74
</Message>
75
<Marker role="status">
76
<MarkerContent class="shimmer">
77
<span class="font-medium">Oliver</span> is typing...
78
</MarkerContent>
79
</Marker>
80
</div>
81
);
82
}

The Message component lays out a single message in a conversation. It handles the avatar, alignment, header, and footer around the message surface.

For AI apps, you can render reasoning steps, tool calls and assistant messages using the Message component.

Installation

pnpm dlx shadcn@latest add @zaidan/message
npx shadcn@latest add @zaidan/message
yarn dlx shadcn@latest add @zaidan/message
bunx --bun shadcn@latest add @zaidan/message

Usage

1
import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar";
2
import { Bubble, BubbleContent } from "~/components/ui/bubble";
3
import { Message, MessageAvatar, MessageContent } from "~/components/ui/message";
1
<Message>
2
<MessageAvatar>
3
<Avatar>
4
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
5
<AvatarFallback>CN</AvatarFallback>
6
</Avatar>
7
</MessageAvatar>
8
<MessageContent>
9
<Bubble>
10
<BubbleContent>How can I help you today?</BubbleContent>
11
</Bubble>
12
</MessageContent>
13
</Message>

Note: Message owns the row layout—avatar, alignment, header, and footer. Render the visible message surface inside it with Bubble. For the scroll container around a conversation, use MessageScroller.

Composition

Use the following composition to build a message:

Message
├── MessageAvatar
└── MessageContent
├── MessageHeader
├── Bubble
└── MessageFooter

Use MessageGroup to stack consecutive messages from the same sender:

MessageGroup
├── Message
└── Message

Features

  • Start and end alignment for sender and receiver rows via the align prop
  • Avatar slot that anchors to the bottom of the message and stays clear of the footer
  • Header and footer slots for sender names, status, and message actions
  • Footer follows the message side; actions stay aligned on align="end" rows
  • Group wrapper for stacking consecutive messages from the same sender
  • Customizable styling through the class prop on every part

Avatar

Use MessageAvatar to render an avatar next to the message. Set align="end" on the message to align the avatar to the end of the message.

R
The build failed during dependency installation.
R
Can you share the exact error?
R
Here's the error from the logs
Something went wrong with the build. The libraries are not installed correctly. Try running the build again.
1
import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar";
2
import { Bubble, BubbleContent, BubbleGroup } from "~/components/ui/bubble";
3
import { Message, MessageAvatar, MessageContent } from "~/components/ui/message";
4
5
export default function MessageAvatarDemo() {
6
return (
7
<div class="flex w-full max-w-sm flex-col gap-6 py-12">
8
<Message>
9
<MessageAvatar>
10
<Avatar>
11
<AvatarImage src="https://github.com/evilrabbit.png" alt="@avatar" />
12
<AvatarFallback>R</AvatarFallback>
13
</Avatar>
14
</MessageAvatar>
15
<MessageContent>
16
<Bubble variant="muted">
17
<BubbleContent>The build failed during dependency installation.</BubbleContent>
18
</Bubble>
19
</MessageContent>
20
</Message>
21
<Message align="end">
22
<MessageAvatar>
23
<Avatar>
24
<AvatarImage src="https://github.com/shadcn.png" alt="@avatar" />
25
<AvatarFallback>R</AvatarFallback>
26
</Avatar>
27
</MessageAvatar>
28
<MessageContent>
29
<Bubble>
30
<BubbleContent>Can you share the exact error?</BubbleContent>
31
</Bubble>
32
</MessageContent>
33
</Message>
34
<Message>
35
<MessageAvatar>
36
<Avatar>
37
<AvatarImage src="https://github.com/evilrabbit.png" alt="@avatar" />
38
<AvatarFallback>R</AvatarFallback>
39
</Avatar>
40
</MessageAvatar>
41
<MessageContent>
42
<BubbleGroup>
43
<Bubble variant="muted">
44
<BubbleContent>Here's the error from the logs</BubbleContent>
45
</Bubble>
46
<Bubble variant="muted">
47
<BubbleContent>
48
Something went wrong with the build. The libraries are not installed correctly. Try
49
running the build again.
50
</BubbleContent>
51
</Bubble>
52
</BubbleGroup>
53
</MessageContent>
54
</Message>
55
</div>
56
);
57
}
alignDescription
startAlign the message to the start of the conversation.
endAlign the message to the end of the conversation.

Group

Use MessageGroup to stack consecutive messages from the same sender. Render an empty MessageAvatar on the earlier messages to keep them aligned with the avatar on the last one.

I checked the registry addresses.
CN
The component and example JSON now live under the UI registry.
1
import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar";
2
import { Bubble, BubbleContent } from "~/components/ui/bubble";
3
import {
4
Message,
5
MessageAvatar,
6
MessageContent,
7
MessageGroup,
8
} from "~/components/ui/message";
9
10
export default function MessageGroupDemo() {
11
return (
12
<div class="flex w-full max-w-sm flex-col gap-6 py-12">
13
<MessageGroup>
14
<Message>
15
<MessageAvatar />
16
<MessageContent>
17
<Bubble variant="muted">
18
<BubbleContent>I checked the registry addresses.</BubbleContent>
19
</Bubble>
20
</MessageContent>
21
</Message>
22
<Message>
23
<MessageAvatar>
24
<Avatar>
25
<AvatarImage src="https://github.com/evilrabbit.png" alt="@avatar" />
26
<AvatarFallback>CN</AvatarFallback>
27
</Avatar>
28
</MessageAvatar>
29
<MessageContent>
30
<Bubble variant="muted">
31
<BubbleContent>
32
The component and example JSON now live under the UI registry.
33
</BubbleContent>
34
</Bubble>
35
</MessageContent>
36
</Message>
37
</MessageGroup>
38
</div>
39
);
40
}

Header and Footer

Use MessageHeader for a sender name and MessageFooter for metadata such as a delivery or read status.

Olivia
I already checked the logs.
Send the report to the team. Ping @shadcn if you need help.
Read Yesterday
1
import { Bubble, BubbleContent } from "~/components/ui/bubble";
2
import {
3
Message,
4
MessageContent,
5
MessageFooter,
6
MessageHeader,
7
} from "~/components/ui/message";
8
9
export default function MessageHeaderFooterDemo() {
10
return (
11
<div class="flex w-full max-w-sm flex-col gap-8 py-12">
12
<Message>
13
<MessageContent>
14
<MessageHeader>Olivia</MessageHeader>
15
<Bubble variant="muted">
16
<BubbleContent>I already checked the logs.</BubbleContent>
17
</Bubble>
18
</MessageContent>
19
</Message>
20
<Message align="end">
21
<MessageContent>
22
<Bubble>
23
<BubbleContent>
24
Send the report to the team. Ping @shadcn if you need help.
25
</BubbleContent>
26
</Bubble>
27
<MessageFooter>
28
<div>
29
Read <span class="font-normal">Yesterday</span>
30
</div>
31
</MessageFooter>
32
</MessageContent>
33
</Message>
34
</div>
35
);
36
}

Actions

Place message-level actions in MessageFooter, such as copy, retry, or feedback buttons.

The install failure is coming from the workspace package.
Okay drop me a link. Taking a look...
Failed to send
1
import { CopyIcon, RefreshCcwIcon, ThumbsDownIcon, ThumbsUpIcon } from "lucide-solid";
2
3
import { Bubble, BubbleContent } from "~/components/ui/bubble";
4
import { Button } from "~/components/ui/button";
5
import { Message, MessageContent, MessageFooter } from "~/components/ui/message";
6
7
export default function MessageActionsDemo() {
8
return (
9
<div class="flex w-full max-w-sm flex-col gap-8 py-12">
10
<Message>
11
<MessageContent>
12
<Bubble variant="muted">
13
<BubbleContent>The install failure is coming from the workspace package.</BubbleContent>
14
</Bubble>
15
<MessageFooter>
16
<Button variant="ghost" size="icon" aria-label="Copy" title="Copy">
17
<CopyIcon />
18
</Button>
19
<Button variant="ghost" size="icon" aria-label="Like" title="Like">
20
<ThumbsUpIcon />
21
</Button>
22
<Button variant="ghost" size="icon" aria-label="Dislike" title="Dislike">
23
<ThumbsDownIcon />
24
</Button>
25
</MessageFooter>
26
</MessageContent>
27
</Message>
28
<Message align="end">
29
<MessageContent>
30
<Bubble>
31
<BubbleContent>Okay drop me a link. Taking a look...</BubbleContent>
32
</Bubble>
33
<MessageFooter class="gap-2">
34
<span class="font-normal text-destructive">Failed to send</span>
35
<Button variant="ghost" size="icon-xs" title="Retry" aria-label="Retry">
36
<RefreshCcwIcon />
37
</Button>
38
</MessageFooter>
39
</MessageContent>
40
</Message>
41
</div>
42
);
43
}

Attachment

Workspace
Here's the image. Can you add it to the PDF? Use it for the cover page.
Done. Here's the PDF with the image added as the cover page.
sales-dashboard.pdfPDF · 2.4 MB
Thanks. Looks good.
1
import { DownloadIcon, FileTextIcon } from "lucide-solid";
2
3
import {
4
Attachment,
5
AttachmentAction,
6
AttachmentActions,
7
AttachmentContent,
8
AttachmentDescription,
9
AttachmentMedia,
10
AttachmentTitle,
11
} from "~/components/ui/attachment";
12
import { Bubble, BubbleContent } from "~/components/ui/bubble";
13
import { Message, MessageContent } from "~/components/ui/message";
14
15
export default function MessageAttachmentDemo() {
16
return (
17
<div class="flex w-full max-w-sm flex-col gap-8 py-12">
18
<Message align="end">
19
<MessageContent>
20
<Attachment orientation="vertical">
21
<AttachmentMedia variant="image">
22
<img
23
src="https://images.unsplash.com/photo-1497366754035-f200968a6e72?w=900&auto=format&fit=crop&q=80"
24
alt="Workspace"
25
/>
26
</AttachmentMedia>
27
</Attachment>
28
<Bubble>
29
<BubbleContent>
30
Here's the image. Can you add it to the PDF? Use it for the cover page.
31
</BubbleContent>
32
</Bubble>
33
</MessageContent>
34
</Message>
35
<Message>
36
<MessageContent>
37
<Bubble variant="muted">
38
<BubbleContent>
39
Done. Here's the PDF with the image added as the cover page.
40
</BubbleContent>
41
</Bubble>
42
<Attachment>
43
<AttachmentMedia>
44
<FileTextIcon />
45
</AttachmentMedia>
46
<AttachmentContent>
47
<AttachmentTitle>sales-dashboard.pdf</AttachmentTitle>
48
<AttachmentDescription>PDF · 2.4 MB</AttachmentDescription>
49
</AttachmentContent>
50
<AttachmentActions>
51
<AttachmentAction
52
type="button"
53
title="Download"
54
aria-label="Download"
55
size="icon-sm"
56
variant="secondary"
57
>
58
<DownloadIcon />
59
</AttachmentAction>
60
</AttachmentActions>
61
</Attachment>
62
</MessageContent>
63
</Message>
64
<Message align="end">
65
<MessageContent>
66
<Bubble>
67
<BubbleContent>Thanks. Looks good.</BubbleContent>
68
</Bubble>
69
</MessageContent>
70
</Message>
71
</div>
72
);
73
}

Accessibility

Message is a presentational layout wrapper. Accessibility comes from the content you place inside it.

Label icon-only actions

Action buttons in MessageFooter are usually icon-only, so give each one an aria-label.

1
<MessageFooter>
2
<Button variant="ghost" size="icon" aria-label="Copy">
3
<CopyIcon />
4
</Button>
5
</MessageFooter>

Status updates

For in-progress messages, use a Marker with role="status" so assistive tech announces the update as it appears.

1
<Message>
2
<Marker role="status">
3
<MarkerIcon>
4
<Spinner />
5
</MarkerIcon>
6
<MarkerContent>Checking the logs...</MarkerContent>
7
</Marker>
8
</Message>

API Reference

Message

The message row wrapper.

PropTypeDefaultDescription
align"start" | "end""start"The alignment of the message in the conversation.
classstring-Additional classes to apply to the row.

MessageGroup

Groups consecutive messages from the same sender.

PropTypeDefaultDescription
classstring-Additional classes to apply to the group root.

MessageAvatar

The avatar slot, aligned to the bottom of the message. When the message has a MessageFooter, the avatar shifts up to stay aligned with the message surface instead of the footer.

PropTypeDefaultDescription
classstring-Additional classes to apply to the avatar slot.

MessageContent

Wraps the header, message surface, and footer.

PropTypeDefaultDescription
classstring-Additional classes to apply to the content slot.

MessageHeader

Displays content above the message, such as a sender name. Stays aligned to the start regardless of align.

PropTypeDefaultDescription
classstring-Additional classes to apply to the header.

MessageFooter

Displays content below the message, such as status or actions. Aligns to the message side.

PropTypeDefaultDescription
classstring-Additional classes to apply to the footer.

On This Page

  • Installation
  • Usage
  • Composition
  • Features
  • Avatar
  • Group
  • Header and Footer
  • Actions
  • Attachment
  • Accessibility
    • Label icon-only actions
    • Status updates
  • API Reference
    • Message
    • MessageGroup
    • MessageAvatar
    • MessageContent
    • MessageHeader
    • MessageFooter
Built by Kevin Abatan. The source code is available on GitHub.