Get started
Data display
Data entry
General
Layout
Navigation
Blocks
Packages
One chat message row over upstream Message, with a line beside its leading edge while its text is still streaming.
Hello - any updates?
Assistant
Looking now - will report back shortly.
tsx
1
2
3import type { ReactNode } from 'react';
import { ChatMessage, ChatMessageAccent } from '@/registry/bases/base-ui/components/data-display/chat-message';Installation#
bash
pnpm dlx shadcn@latest add https://ui.zeroxsolutions.com/r/chat-message.jsonUsage#
tsx
import { ChatMessage, ChatMessageAccent } from '@/components/data-display/chat-message';The consumer composes the row from upstream Message parts, and adds a ChatMessageAccent while the row
streams:
tsx
<ChatMessage streaming style={{ '--chat-message-accent': agent.color } as CSSProperties}>
<ChatMessageAccent />
<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 upstream Message.
Composition#
text
ChatMessage
|-- ChatMessageAccent
`-- MessageContent
|-- MessageHeader
`-- Bubble
`-- BubbleContentAPI reference#
ChatMessage#
Renders shadcn's Message and takes every prop it takes,
plus:
| Prop | Type | Default |
|---|---|---|
streaming | boolean | false |
It sets data-slot="chat-message" and data-streaming while streaming.
ChatMessageAccent#
Renders a span and takes every prop a span takes. It is hidden from assistive technology, shown only while
its row streams, and painted in --chat-message-accent (any CSS colour set on the row, such as the agent's), or
--primary when that is unset. It sets data-slot="chat-message-accent" and aria-hidden.