Chat thread
A chat thread with grouped messages, reactions, read receipts, typing, and a composer with attachments.
npx shadcn@latest add @silicon-ui/chat-threadInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/chat-threadManually
Install the dependencies
npm install lucide-react motionCopy these files into your project
- components/silicon-ui/chat-thread/chat-thread.tsx
- components/silicon-ui/chat-thread/chat-thread.module.css
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
ChatThread
| Prop | Type | Default |
|---|---|---|
participants* | ChatParticipant[] | โ |
currentUserId* | string | โ |
messagesControlled messages, oldest first. Leave it out to let the thread keep its own list. | ChatMessage[] | โ |
defaultMessages | ChatMessage[] | โ |
typingParticipant ids currently typing. | string[] | [] |
readByThe last message each participant has read, by participant id. Their avatar sits under that message and glides as it moves. | Record<string, string> | โ |
onSendCalled with the composer's text and files. Uncontrolled threads also append the message themselves. | (draft: ChatDraft) => void | Promise<void> | โ |
onReact | (messageId: string, emoji: string) => void | โ |
onRetry | (messageId: string) => void | โ |
reactionsEmoji offered by the reaction picker. | string[] | DEFAULT_REACTIONS |
placeholder | string | "Message" |
composerShow the composer. Defaults to true. | boolean | true |
allowAttachments | boolean | true |
acceptFile types the attach button offers, as for `<input accept>`. | string | โ |
groupWindowMessages from one person closer together than this, in ms, share a group. Defaults to five minutes. | number | 5 * 60_000 |
locale | string | "en-US" |
labelAccessible name of the message log. | string | "Conversation" |
labelsWords for localization. Leave out any key to keep its English default. | ChatThreadLabels | โ |
className | string | โ |
Also accepts the props of HTMLAttributes.
ChatComposer
| Prop | Type | Default |
|---|---|---|
onSend* | (draft: ChatDraft) => void | โ |
placeholder | string | "Message" |
allowAttachments | boolean | true |
accept | string | โ |
disabled | boolean | โ |
labelsWords for localization. Leave out any key to keep its English default. | ChatComposerLabels | โ |
className | string | โ |
Also accepts the props of HTMLAttributes.
Dependencies
- npm
- lucide-reactmotion
- Registry
- silicon-motion-tokens