Get started
Forms
- 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
Display
- 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
Layout
One chat message row over Message, with a line beside its leading edge while its text is still streaming.
Installation#
bash
pnpm dlx shadcn@latest add @zui/chat-messageThe CLI writes components/data-display/chat-message.tsx, installs
Direction, Message and Utils.
Usage#
tsx
import { ChatMessage, ChatMessageAccent } from '@/components/data-display/chat-message';Compose the row from Message's parts, and add a ChatMessageAccent
while the row streams:
tsx
<ChatMessage streaming>
<ChatMessageAccent className="bg-chart-2" />
<MessageContent>
<MessageHeader>{agent.name}</MessageHeader>
<Bubble variant="ghost">
<BubbleContent>{text}</BubbleContent>
</Bubble>
</MessageContent>
</ChatMessage>Use it to mark a row as still streaming; a static row needs only Message.
Composition#
text
ChatMessage
|-- ChatMessageAccent
`-- MessageContent
|-- MessageHeader
`-- Bubble
`-- BubbleContentAPI reference#
ChatMessage#
Takes every prop of Message, plus:
| Prop | Type | Default |
|---|---|---|
streaming | boolean | false |
ChatMessageAccent#
Takes every prop of React Native's View. The line 12px before the row's leading edge, drawn only while the row
streams and hidden from a screen reader. It is painted in the primary colour, or in the colour a className or
style gives it, such as the agent's. It sits outside the row, so the list around the row needs room there.
Differences from the web#
- The accent takes its colour from its own
classNameorstyle; the web reads a--chat-message-accentCSS variable set on the row, which neither engine passes from a parent's style to a child. - The accent is not rendered while the row is not streaming; the web keeps it in the page and hides it by a group selector.
- The web's
data-slotanddata-streamingattributes are not set; a View takes no data attributes.