Messenger Pro
The parts of a chat between people, as WhatsApp, iMessage, Telegram and Slack build them.
ConversationListis the inbox: pinned first, presence, who's typing, drafts, the last message with read ticks, unread counts, and swipe actions.MessengerThreadis the conversation: day headings, a New messages line, quoted replies that jump to the original, albums, videos, files, links, places, contacts, polls, voice messages, stickers, light formatting and @mentions, reactions, read ticks, and a long-press menu to react, reply, forward, copy, edit, pin, star, select, see who read it, or delete.MessengerComposeris its message box, on its own: attachments, emoji, @mentions, a reply or edit bar, and hold-to-record voice messages.ChatDetailsis the panel about a conversation: its people, starred messages, and its media, files and links.ChannelThreadis a Slack-style channel: plain rows, reaction chips and threads.
For an assistant that streams replies, use AI Chat. MessengerScreen and TeamChatScreen put the parts together with demo people, ready to rename.
import { ChannelThread, ChatDetails, ConversationList, MessengerComposer, MessengerThread, MessengerScreen } from '@patine-ui/pro';
<MessengerScreen />
Example: a team thread
A design team's group chat: names beside others' messages, a reply quoted in its bubble, reactions, read receipts on your own, and your messages added as you send them. Long-press a message (or hover it on the web) for its menu.
<View style={{ height: 520, width: '100%', maxWidth: 420 }}> <MessengerThread messages={messages} users={USERS} me="me" group typing={['Leo']} onSend={send} onReact={react} onEdit={edit} /> </View>
The thread
MessengerThread is controlled: pass the messages, the people by id and your own id, and handle onSend. It tells you what the new message replies to, and which files go with it. Each handler you pass adds its action: onEdit adds Edit, onDelete adds Delete (for everyone on your own messages, for you on any), onForward with forwardTargets adds Forward, onPin and onStar add Pin and Star.
<MessengerThread
messages={messages}
users={users}
me="me"
group
lastReadAt={lastReadAt}
typing={['Maya']}
onSend={(text, { replyTo, attachments }) => api.send({ text, replyTo, attachments })}
onReact={(id, emoji) => api.react(id, emoji)}
onEdit={(id, text) => api.edit(id, text)}
onDelete={(ids, forEveryone) => api.remove(ids, forEveryone)}
forwardTargets={chats}
onForward={(ids, chatIds) => api.forward(ids, chatIds)}
pinnedIds={pinnedIds}
onPin={api.togglePin}
onStar={api.toggleStar}
onCopy={Clipboard.setStringAsync}
/>
A message is { id, senderId, text?, createdAt, status?, replyTo?, reactions?, attachments?, voice?, link?, location?, contact?, poll?, sticker?, edited?, deleted?, forwarded?, starred?, readBy?, deliveredTo?, system? }.
- Ticks. Your own messages show
status: a clock whilesending, one ticksent, twodelivered, two in blueread. Each step pops in. Info listsreadByanddeliveredTowith their times. - Formatting.
texttakes*bold*,_italic_,~strike~,`code`, code blocks, links and@mentionsof people inusers; a mention of you is tinted. A few emoji alone draw large. - Replies.
replyTodraws the quoted message; tap it to jump there and flash it. Swipe a message to reply. - Deleted.
deleteddraws "This message was deleted". - System lines.
systemmessages are a line in the middle ("Maya added Ana").
Photos, files and cards
attachments group by kind. Photos and videos make an album (two side by side, three as one large and two small, four or more as a grid with "+N"), videos show their length, and a tap opens the viewer. Other files are cards with their type, size, upload progress and Download. link draws a preview card, location a map (live with liveUntil), contact a card with Message and Save, and poll a poll to vote in with animated results.
Voice messages
Hold the mic to record, slide left to cancel, slide up to lock and let go. onRecordStart and onRecordEnd start and stop your recorder (for example expo-audio), amplitude (0 to 1) draws the live waveform, and onSendVoice gets { durationMs, waveform }. A message with voice: { durationMs, waveform? } draws a play button and its waveform; onPlayVoice gets the message, and playing says which one plays.
Search, pins and select
The search bar (searchOpen, onSearchOpenChange) marks matches, steps through them with up and down, and jumps to a date; tap a day heading to jump too. Pinned messages ride a bar at the top that cycles through them. Select from the menu ticks messages to star, copy, forward or delete together. Scrolled up, a button jumps back to the latest with how many arrived. onLoadOlder, hasOlder and loadingOlder page in older messages with a spinner.
The composer
MessengerThread brings its own; use MessengerComposer alone under your own list. variant="pill" is a rounded field with a send button that turns into the mic, as phones do; variant="box" is a bordered box with a toolbar, as Slack does. Type @ for a list of people to mention (arrow keys and Enter on the web).
<MessengerComposer
value={draft}
onValueChange={setDraft}
onSend={send}
users={users}
me="me"
context={replyTo ? { kind: 'reply', title: `Replying to ${replyTo.name}`, text: replyTo.text, onCancel: clearReply } : undefined}
onAttach={(kind) => pick(kind)}
onSendVoice={sendVoice}
/>
The details panel
ChatDetails shows a conversation's picture and name, call and search shortcuts, a mute switch, starred messages, Media, Files and Links tabs built from its messages, and its members with presence.
<ChatDetails title="Lisbon crew" group participants={people} messages={messages} me="me" muted={muted} onMutedChange={setMuted} onSearch={openSearch} />
The inbox
<ConversationList
conversations={conversations}
me="me"
users={users}
active={openId}
onSelect={open}
onPin={togglePin}
onMute={toggleMute}
onArchive={archive}
header={<SearchField value={query} onValueChange={setQuery} />}
/>
A conversation is { id, title, avatar?, group?, online?, lastMessage?, unread?, muted?, pinned?, typing?, draft? }. A muted one's count is grey, and draft shows as "Draft: …". Swipe actions show only for the handlers you pass.
Team chat
ChannelThread draws a channel as Slack does: no bubbles, the avatar and name heading each run, reactions as chips that toggle yours, and a message's thread: { count, userIds, lastReplyAt } as faces and a reply count that call onOpenThread. Hover a message on the web for three quick reactions, Reply in thread and its menu. For the thread's panel, pass the parent and its replies with plain.
<View style={{ height: 420, width: '100%' }}> <ChannelThread messages={messages} users={USERS} me="me" onSend={send} onReact={react} onOpenThread={() => {}} placeholder="Message #launch" /> </View>
Accessibility
- Each message reads as one line: who, what, when, edited, starred and its receipt, with an action to open its menu.
- The menu has the menu role; reactions are buttons with who reacted, and Slack's chips are toggle buttons.
- Day headings are headings, and the composer says what you're replying to or editing, with a labelled Cancel.
- Swipe to reply and hover actions are shortcuts: everything is also in the long-press menu. Screen readers start a voice message locked, with Send and Discard on screen.
- Escape closes the menu, select mode and search on the web.
Props
MessengerThread
| Prop | Type | Default |
|---|---|---|
messages | MessengerMessage[], oldest first | |
users | Record<id, { id, name, avatar?, online?, role? }> | |
me | string, your user id | |
group | boolean: names and avatars beside others' messages | false |
lastReadAt | number: the New messages line goes after it | |
typing | string[], names | [] |
onSend | (text, { replyTo?, attachments }) => void | |
onReact | (messageId, emoji) => void | |
onEdit, editWindowMs | (messageId, text) => void, number | no limit |
onDelete | (messageIds, forEveryone) => void | |
onForward, forwardTargets | (messageIds, targetIds) => void, { id, title, avatar?, subtitle? }[] | |
onPin, pinnedIds | (messageId) => void, string[] | |
onStar | (messageIds) => void | |
onCopy | (text) => void: adds Copy | |
onAttach, attachKinds | (kind) => files | undefined, ('photo' | 'camera' | 'document' | 'location' | 'contact')[] | |
onSendPoll | (poll) => void: adds Poll to + | |
onVote | (messageId, optionIds) => void | |
onSendVoice, onRecordStart, onRecordEnd, amplitude | voice recording | |
onPlayVoice, playing | (message) => void, string | |
onOpenLink, onOpenAttachment, onDownload, onOpenLocation, onContactAction | open what a message carries | |
onLoadOlder, hasOlder, loadingOlder | () => void, boolean, boolean | |
searchOpen, onSearchOpenChange | boolean, (open) => void | |
banner | ReactNode, over the messages | |
labels | Partial<MessengerLabels> | English |
ChannelThread
The thread's messages, users, me, lastReadAt, typing, onReact, onEdit, onDelete, onPin, pinnedIds, onStar, onCopy, onAttach and the open handlers, plus:
| Prop | Type | Default |
|---|---|---|
onSend | (text, { attachments }) => void | |
onOpenThread | (messageId) => void: the replies summary and Reply in thread | |
plain | boolean: a thread's panel, the parent first with a reply count under it | false |
header | ReactElement, at the top of the list | |
composerFooter | ReactNode, under the box: "Also send to #design" |
ConversationList
| Prop | Type | Default |
|---|---|---|
conversations | MessengerConversation[] | |
me | string | |
users | Record<id, MessengerUser>, for "Maya: …" in groups | |
active | string | |
onSelect | (id) => void | |
onPin, onMute, onArchive | (id) => void: swipe actions | |
header | ReactElement, above the rows |
MessengerComposer
| Prop | Type | Default |
|---|---|---|
value, onValueChange | string, (text) => void | |
onSend | (text) => void | |
variant | 'pill' | 'box' | 'pill' |
users, me | who @ suggests | |
context | { kind: 'reply' | 'edit', title, text, onCancel } | |
pending, onRemovePending | files waiting to go | |
onAttach, attachKinds | the + menu | |
onSendVoice, onRecordStart, onRecordEnd, amplitude | voice recording | |
footer | ReactNode, under the box in 'box' |
ChatDetails
| Prop | Type | Default |
|---|---|---|
title, avatar, subtitle, group | the conversation | |
participants | MessengerUser[] | |
messages, me | for the starred messages and the Media, Files and Links tabs | |
muted, onMutedChange | boolean, (muted) => void | |
onSearch, onAudioCall, onVideoCall, onClose | () => void | |
onSelectMessage | (messageId) => void: a starred message |
Related
- Team chat: a Slack-style screen built from
ChannelThread. - AI Chat: an assistant that streams.
- MessageBubble & ChatComposer: the free parts.