Skip to main content

Messenger Pro

The parts of a chat between people, as WhatsApp, iMessage, Telegram and Slack build them.

  • ConversationList is the inbox: pinned first, presence, who's typing, drafts, the last message with read ticks, unread counts, and swipe actions.
  • MessengerThread is 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.
  • MessengerComposer is its message box, on its own: attachments, emoji, @mentions, a reply or edit bar, and hold-to-record voice messages.
  • ChatDetails is the panel about a conversation: its people, starred messages, and its media, files and links.
  • ChannelThread is 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';
Loading…
<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.

Loading…
<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 while sending, one tick sent, two delivered, two in blue read. Each step pops in. Info lists readBy and deliveredTo with their times.
  • Formatting. text takes *bold*, _italic_, ~strike~, `code`, code blocks, links and @mentions of people in users; a mention of you is tinted. A few emoji alone draw large.
  • Replies. replyTo draws the quoted message; tap it to jump there and flash it. Swipe a message to reply.
  • Deleted. deleted draws "This message was deleted".
  • System lines. system messages 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.

Loading…
<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​

PropTypeDefault
messagesMessengerMessage[], oldest first
usersRecord<id, { id, name, avatar?, online?, role? }>
mestring, your user id
groupboolean: names and avatars beside others' messagesfalse
lastReadAtnumber: the New messages line goes after it
typingstring[], names[]
onSend(text, { replyTo?, attachments }) => void
onReact(messageId, emoji) => void
onEdit, editWindowMs(messageId, text) => void, numberno 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, amplitudevoice recording
onPlayVoice, playing(message) => void, string
onOpenLink, onOpenAttachment, onDownload, onOpenLocation, onContactActionopen what a message carries
onLoadOlder, hasOlder, loadingOlder() => void, boolean, boolean
searchOpen, onSearchOpenChangeboolean, (open) => void
bannerReactNode, over the messages
labelsPartial<MessengerLabels>English

ChannelThread​

The thread's messages, users, me, lastReadAt, typing, onReact, onEdit, onDelete, onPin, pinnedIds, onStar, onCopy, onAttach and the open handlers, plus:

PropTypeDefault
onSend(text, { attachments }) => void
onOpenThread(messageId) => void: the replies summary and Reply in thread
plainboolean: a thread's panel, the parent first with a reply count under itfalse
headerReactElement, at the top of the list
composerFooterReactNode, under the box: "Also send to #design"

ConversationList​

PropTypeDefault
conversationsMessengerConversation[]
mestring
usersRecord<id, MessengerUser>, for "Maya: …" in groups
activestring
onSelect(id) => void
onPin, onMute, onArchive(id) => void: swipe actions
headerReactElement, above the rows

MessengerComposer​

PropTypeDefault
value, onValueChangestring, (text) => void
onSend(text) => void
variant'pill' | 'box''pill'
users, mewho @ suggests
context{ kind: 'reply' | 'edit', title, text, onCancel }
pending, onRemovePendingfiles waiting to go
onAttach, attachKindsthe + menu
onSendVoice, onRecordStart, onRecordEnd, amplitudevoice recording
footerReactNode, under the box in 'box'

ChatDetails​

PropTypeDefault
title, avatar, subtitle, groupthe conversation
participantsMessengerUser[]
messages, mefor the starred messages and the Media, Files and Links tabs
muted, onMutedChangeboolean, (muted) => void
onSearch, onAudioCall, onVideoCall, onClose() => void
onSelectMessage(messageId) => void: a starred message