- Label
- Icon label
- Field
- Form
- Frontmatter form
- Questionnaire
- Input
- Input group
- Input OTP
- Password input
- Password strength
- Code input
- Number field
- Tag input
- Textarea
- Checkbox
- Radio group
- Language toggle group
- Emoji appearance toggle group
- Emoji picker
- Avatar picker
- AI provider picker
- Select
- Native select
- Combobox
- Language combobox
- Slider
- Calendar
- Switch
- Alert
- Avatar
- Badge
- Card
- AI provider card
- Model info card
- Model list
- Empty
- Item
- Tree item
- File tree
- Icon media
- File type icon
- Font preview
- Image preview
- Kbd
- Table
- Data table
- Data table column header
- Chart
- Code Block
- Code card
- Markdown view
- Attachment
- Bubble
- Marker
- Message
- Chat message
- Chat suggestion item
- Message scroller
- Trace
- Progress
- Spinner
- Sonner
- Toast
- Unsaved changes toolbar
- Unsaved indicator
- Status indicator
- Permission card
- Separator
- Skeleton
- Animated grid pattern
- Meteors
One message in a conversation, with an avatar, a header and a footer, on either side of the row.
Installation#
pnpm dlx shadcn@latest add @zui/messageThe CLI writes components/ui/message.tsx, installs Text, Message context
(lib/message-context.ts, which tells a Bubble or an
Attachment inside the message its side) and Utils.
Usage#
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { Bubble, BubbleContent } from '@/components/ui/bubble';
import { Message, MessageAvatar, MessageContent, MessageFooter } from '@/components/ui/message';
import { Text } from '@/components/ui/text';<Message align="end">
<MessageAvatar>
<Avatar alt="@me">
<AvatarImage source={{ uri: avatarUrl }} />
<AvatarFallback>
<Text>ME</Text>
</AvatarFallback>
</Avatar>
</MessageAvatar>
<MessageContent>
<Bubble>
<BubbleContent>It's a one-line change.</BubbleContent>
</Bubble>
<MessageFooter>Delivered</MessageFooter>
</MessageContent>
</Message>For a message still being written, put a Marker with role="status"
below it.
API reference#
Message#
Takes every prop of React Native's View, plus:
| Prop | Type | Default |
|---|---|---|
align | 'start' | 'end' | 'start' |
end puts the avatar on the other side and moves the content's parts to the end of the row.
MessageAvatar#
Takes every prop of React Native's View. Sits at the bottom of the message; while the message has a
MessageFooter, it is lifted level with the last bubble rather than the footer.
MessageContent#
Takes every prop of React Native's View, and takes the width the avatar leaves.
MessageHeader, MessageFooter#
Each takes every prop of React Native's View, and sets text given straight to it in a small muted Text. Both
are inset to line up with a framed bubble, and drop the inset while the message holds a ghost bubble. Put
message actions, such as copy or retry buttons, in the footer.
MessageGroup#
Takes every prop of React Native's View, and stacks consecutive messages from one sender.
Differences from upstream#
- Upstream's message finds its footer and a ghost bubble with
:has()selectors. The native parts tell the message they are there, and a Bubble or an Attachment reads the message's side, throughlib/message-context.ts. - Upstream's demo shimmers "is typing..." with shadcn's
shimmerclass, which has no native counterpart.