Skip to content

React Chat UI

A React chat UI for one conversation: bubbles grouped by sender, sticky day labels, replies, reactions, photos and typing.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/chat.json
  • ChatThread
  • TypingDots
  • EmojiPicker
  • ChatComposer
  • ImageLightbox
  • +5 more
  • +2 more

Direct chat

Send a message and watch the ticks: sending, sent, delivered, read; then Riya types and replies. Your third message fails: retry it. Hover a message for the toolbar, right-click (or long-press) for every action, or use the keyboard: ↑ ↓ between messages, Enter for actions, R to reply, E to edit. ↑ in an empty composer edits your last message.

Files to copy

22 folders · 37 files · 4 packages
From theme/src/
  • components/chat/{chat-thread.tsx, composer.tsx, message-row.tsx, chat-parts.tsx, emoji-picker.tsx, emoji.ts, format.ts, hooks.ts, icons.tsx, labels.ts, message-parts.tsx, toolbar-store.ts, types.ts}
  • components/alert-dialog/
  • components/avatar/
  • components/button/
  • components/chat/thread/
  • components/context-menu/
  • components/description-list/
  • components/dialog/
  • components/drawer/
  • components/file-upload/file-utils.ts
  • components/input/
  • components/kbd/
  • components/menu/
  • components/popover/
  • components/skeleton/
  • components/spinner/
  • components/status-icons/
  • components/tooltip/
  • hooks/{use-controllable.ts, use-direction.ts, use-latest.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts}
  • motion/{gate.ts, presets.ts, tokens.ts}
  • lib/{cn.ts, field-size.ts, form.ts, glide-highlight.tsx, heading.ts, ime.ts, initials.ts, modal-flag.ts, modal-tab-trap.ts, popup-a11y.ts, popup-motion.ts, state-light.tsx, uid.ts, warn-once.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/chat.jsonRegistry item: chat. The styles need the Tailwind v4 glass UI setup.
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Group chat

Sender names and avatars on the first message of each run, system notes, a four-photo grid with “+2”, and reactions from several people.

Props

PropTypeDefaultDescription
conversation (required)ChatConversationNoneThe conversation being shown (kind, title, members).
messages (required)ChatMessage[]NoneThe messages of the conversation, oldest first: the thread shows them in this order, newest at the bottom.
participants (required)ChatParticipant[]NoneEveryone who can appear in the chat (names, avatars, presence).
currentUserId (required)stringNoneYour id: your messages sit on the right (left in RTL) in the accent colour.
onSend((draft: ChatDraft) => void)NoneThe composer sent a message. Add it to messages at once with status "sending" (optimistic), then update it.
onEdit((messageId: string, text: string) => void)NoneCalled when you save an edit of your message.
onDelete((message: ChatMessage) => void)NoneYou confirmed deleting your message. Keep it with deleted: true (it shows a placeholder).
onReact((message: ChatMessage, emoji: string, add: boolean) => void)NoneAdd (add true) or remove your reaction.
onRetry((message: ChatMessage) => void)None"Retry" on a message whose status is "failed".
onLoadOlder(() => void)NoneThe reader reached the top: load earlier messages and prepend them (the scroll position is kept).
hasOlderbooleanfalseThere are earlier messages to load.
loadingOlderbooleanfalseEarlier messages are loading: skeleton bubbles show at the top.
onRead((lastMessageId: string) => void)NoneThe newest message was seen (the reader is at the bottom): mark the chat read.
onTyping((typing: boolean) => void)NoneCalled with true when you start typing and false when you stop.
firstUnreadIdstring | nullNoneShow a "New messages" line above this message (the first unread one when the chat opened).
showHeaderbooleantrueShow the header (avatar, name, presence, call buttons).
onBack(() => void)NoneShows a back button in the header (phones: back to the chat list).
onCall(() => void)NoneShows a call button in the header.
onVideoCall(() => void)NoneShows a video-call button in the header.
onInfo(() => void)NoneShows an info button (opens contact or group info).
headerActionsReactNodeNoneExtra buttons at the end of the header.
headingLevelHeadingLevelOption2Level of the chat's name (2 | 3), or "none" for a paragraph with no heading role (for an example).
headingRefRef<HTMLHeadingElement>NoneThe heading element (to move focus to it, e.g. after opening the chat on a phone).
showComposerbooleantrueShows the message composer below the thread.
draftstringNoneThe unsent text (controlled), e.g. a draft per chat.
onDraftChange((text: string) => void)NoneCalled with the unsent text as it changes.
quickRepliesstring[]NoneChips that send a ready-made reply (support chats).
quickReactionsreadonly string[]defaultQuickReactionsThe reactions offered as one-tap choices on a message.
allowAttachmentsbooleantrueLet people attach files and photos.
acceptstringNoneThe accept attribute of the file picker, e.g. "image/*,.pdf".
composerRefRef<ChatComposerHandle>NoneReceives the ref to the composer's handle (focus(), setText()...).
autoFocusbooleanfalseFocus the composer on mount.
density"compact" | "comfortable""comfortable""compact": smaller type and spacing (the chat widget).
surface"glass" | "none""glass""glass": its own glass panel. "none": no surface (inside ChatApp or your own card).
emptyStateReactNodeNoneShown instead of the log when there are no messages.
nowDateNoneFixes the current time used for relative dates (for tests and screenshots).
localestringNoneBCP 47 locale for times and day labels. Pass one for prerendered pages.
labelsPartial<ChatLabels>defaultChatLabelsAny UI string (i18n); see ChatLabels (every key is listed below the table). Every other string, for translation: labels={{ you: "…" }}; omitted keys keep the English of defaultChatLabels. All 140 keys of ChatLabels are listed in the key table under the props table.
classNamestringNoneAdds extra classes to the outer element.
ChatLabels keys and English defaults (140)
Pass any key in labels; the rest keep the defaults of defaultChatLabels.
KeyEnglish default
youYou
youPrefixYou:
typing(names, group) => { if (!group || names.length === 0) return "typing…"; if (names.length === 1) return `${n...
draftPrefixDraft:
attachmentSummary(kind, count) => kind === "image" ? (count === 1 ? "Photo" : `${count} photos`) : count === 1 ? "File" : `$...
deletedMessageThis message was deleted
deletedOwnMessageYou deleted this message
status{ sending: "Sending", sent: "Sent", delivered: "Delivered", read: "Read", failed: "Not delivered" }
onlineOnline
awayAway
lastSeen(relative) => `Last seen ${relative}`
members(count, online) => online > 0 ? `${plural(count, "member", "members")}, ${online} online` : plural(count, "...
justNownow
chatsChats
searchSearch chats
searchPlaceholderSearch
clearSearchClear search
filtersLabelFilter chats
filters{ all: "All", unread: "Unread", groups: "Groups", archived: "Archived" }
pinnedSectionPinned
allSectionAll chats
unreadCount(count) => plural(count, "unread message", "unread messages")
unreadOverflow99+
pinnedPinned
mutedMuted
listHintArrow keys move between chats, Enter opens one, Shift+F10 shows its actions.
chatActions(name) => `Actions for ${name}`
pinPin
unpinUnpin
muteMute
unmuteUnmute
archiveArchive
unarchiveUnarchive
markReadMark as read
markUnreadMark as unread
loadingChatsLoading chats…
noChatsTitleNo chats yet
noChatsDescriptionWhen you start a conversation, it shows up here.
noResultsTitle(query) => `No chats match “${query}”`
noResultsDescriptionCheck the spelling, or search for a name or a word from a message.
emptyFilter{ unread: "You're all caught up", groups: "No group chats yet", archived: "No archived chats" }
resultsCount(count) => plural(count, "chat", "chats")
messagesWith(title) => `Messages with ${title}`
backBack to chats
callVoice call
videoCallVideo call
contactInfoContact info
groupInfoGroup info
messageRolemessage
newMessagesNew messages
editededited
messageFrom(name, time) => `${name}, ${time}`
replyReply
reactReact
copyCopy text
copiedCopied
copyFailedCouldn't copy. Select the text and copy it instead.
editEdit
deleteDelete
messageInfoMessage info
moreActionsMore actions
retryRetry
notDeliveredNot delivered
deleteTitleDelete this message?
deleteDescriptionIt will be removed for everyone in this chat. This can't be undone.
deleteConfirmDelete for everyone
cancelCancel
closeClose
sentAtSent
deliveredAtDelivered
readAtRead
notYetNot yet
replyingTo(name) => `Replying to ${name}`
cancelReplyCancel reply
editingMessageEditing message
cancelEditCancel editing
goToQuoted(name) => `Go to the message from ${name}`
originalNotLoadedThe original message isn't loaded yet.
jumpToLatestJump to latest message
newBelow(count) => plural(count, "new message", "new messages")
loadingOlderLoading earlier messages…
beginning(title) => `This is the beginning of your chat with ${title}.`
addReactionAdd reaction
moreEmojiMore emoji
reactionChip(emoji, count, mine) => `${emoji} ${count}${mine ? ", including you" : ""}`
reactionsReactions
openImage(name) => `Open ${name}`
imageViewerPhoto
previousImagePrevious photo
nextImageNext photo
imagePosition(index, count) => `${index} of ${count}`
download(name) => `Download ${name}`
morePhotos(count) => `+${count}`
logHintUp and Down arrows move between messages. Enter shows actions, R replies, E edits your own message.
messageMessage
placeholder(title) => (title ? `Message ${title}` : "Write a message…")
sendSend
saveEditSave changes
attachAttach files
emojiEmoji
attachmentsAttachments
removeAttachment(name) => `Remove ${name}`
keyHintEnter to send, Shift + Enter for a new line, Up arrow to edit your last message
keyHintTouchUse the send button to send
editHintEsc to cancel
searchEmojiSearch emoji
noEmojiNo emoji found
emojiCategories{ smileys: "Smileys", people: "People", hearts: "Hearts", nature: "Nature", food: "Food", activities: "Acti...
announceIncoming(name, text) => `${name}: ${text}`
announceFailedMessage not delivered
announceDeletedMessage deleted
announceReaction(emoji, added) => (added ? `Reacted ${emoji}` : `Removed ${emoji}`)
announceOlderLoaded(count) => `Loaded ${plural(count, "earlier message", "earlier messages")}`
announceReplying(name) => `Replying to ${name}. Type your reply.`
announceEditingEditing your message. Press Escape to cancel.
openChatOpen chat
closeChatClose chat
minimizeMinimise chat
widgetTitleSheenUI Support
widgetSubtitleWe typically reply in a few minutes
greetingHi there 👋
greetingDescriptionAsk us anything: we're real people and happy to help.
recentConversationsRecent conversations
sendUsMessageSend us a message
quickRepliesSuggested replies
backToHomeBack
helpHeadingFind an answer
widgetUnread(count) => plural(count, "unread message", "unread messages")
selectChatTitlePick a chat
selectChatDescriptionChoose a conversation from the list to read and reply.
aboutAbout
phonePhone
emailEmail
sharedMediaShared photos
noSharedMediaNo photos shared yet.
muteNotificationsMute notifications
unmuteNotificationsUnmute notifications
block(name) => `Block ${name}`
leaveGroupLeave group
membersHeading(count) => plural(count, "member", "members")

ChatComposer props

PropTypeDefaultDescription
onSend (required)(draft: ChatDraft) => voidNoneCalled with the text, picked files and the quoted message. Hand-over: image preview URLs now belong to you (revoke them when the message goes).
valuestringNoneThe draft text (controlled). Keep a draft per conversation by storing it per id.
defaultValuestring""The draft text on mount (uncontrolled).
onValueChange((text: string) => void)NoneCalled with the text as it changes.
replyToChatReplyRef | nullNoneThe message being replied to: shows a bar above the field with a cancel button.
onCancelReply(() => void)NoneCalled when the reply bar's cancel button is pressed.
editingChatComposerEditing | nullNoneEdit mode: the field holds this message's text; Enter saves, Escape cancels.
onSaveEdit((id: string, text: string) => void)NoneCalled with the message id and new text when an edit is saved.
onCancelEdit(() => void)NoneCalled when an edit is cancelled.
onEditLast(() => void)None↑ in an empty field: start editing your last message.
onTyping((typing: boolean) => void)Nonetrue while the person types, false after 4s of quiet, on send and on blur.
nameOf((participantId: string) => string)NoneName of a sender, for the reply bar.
titlestringNoneThe conversation's name, for the placeholder ("Message Riya").
placeholderstring"Message {title}"Sets the placeholder text.
allowAttachmentsbooleantrueShow the attach button and accept pasted or dropped files.
acceptstringNoneFile types the picker offers (input accept).
maxAttachmentsnumber10Maximum number of files a person can attach to one message.
quickRepliesstring[]NoneText tapped to send at once (support chats): shown as chips above the field.
maxRowsnumber6Tallest the field grows before it scrolls, in lines.
disabledbooleanfalseDisable the field and every button.
autoFocusbooleanfalseFocus the field on mount.
density"compact" | "comfortable""comfortable"Sets the row density: "compact" uses tighter padding (the chat widget).
localestringthe browser'sBCP 47 locale for file sizes.
labelsPartial<ChatLabels>defaultChatLabelsAny UI string (i18n); see ChatLabels (every key is listed below the table). Every other string, for translation: labels={{ you: "…" }}; omitted keys keep the English of defaultChatLabels. All 140 keys of ChatLabels are listed in the key table under the props table.
classNamestringNoneAdds extra classes to the composer.

DeliveryStatus props

PropTypeDefaultDescription
status (required)ChatMessageStatusNone"sending", "sent", "delivered", "read" or "failed".
labels (required)Pick<ChatLabels, "status">defaultChatLabelsThe chat labels; only status (the spoken text per state) is used. Spread defaultChatLabels and override single keys, e.g. labels={{ ...defaultChatLabels, status: "…" }}. Its only key is listed in the key table under the props table.
variant"list" | "bubble""list""bubble": on the accent fill of your own bubble. "list": on glass.
tone"list" | "bubble"undefinedOld name of variant (it is a visual form, not a semantic colour). Still honoured; variant wins.
spokenbooleantrueSay the state to screen readers here (off when you say it elsewhere, e.g. after the text).
classNamestringNoneAdds extra classes to the icon wrapper.

EmojiPicker props

PropTypeDefaultDescription
onSelect (required)(emoji: string) => voidNoneCalled with the emoji character.
categoriesChatEmojiCategory[]defaultEmojiCategoriesThe emoji to offer, by category (defaults to a curated ~170).
frequentreadonly string[]NoneEmoji shown first under "Frequently used" (e.g. the quick reactions).
selectedreadonly string[][]Emoji to mark as chosen (your current reactions): aria-pressed + a tint.
autoFocusSearchbooleanfalseFocus the search field when it mounts (off on touch screens, where it would raise the keyboard).
labelsPartial<ChatLabels>defaultChatLabelsAny UI string (i18n); see ChatLabels (every key is listed below the table). Every other string, for translation: labels={{ you: "…" }}; omitted keys keep the English of defaultChatLabels. All 140 keys of ChatLabels are listed in the key table under the props table.
classNamestringNoneAdds extra classes to the picker.

ImageLightbox props

PropTypeDefaultDescription
images (required)ChatAttachment[]NoneTakes the photos to page through.
index (required)number | null0The open photo's index, or null when closed (controlled).
onIndexChange (required)(index: number | null) => voidNoneCalled with the new index when the person pages, or null to close.
labels (required)ChatLabelsdefaultChatLabelsTranslated text for the viewer: its dialog name, the "2 of 5" position, the previous/next buttons and download. Spread defaultChatLabels and override single keys, e.g. labels={{ ...defaultChatLabels, you: "…" }}. All 140 keys of ChatLabels are listed in the key table under the props table.
captionReactNodeNoneLine under the photo, e.g. "Riya Sharma · Yesterday, 18:40".
finalFocus(() => HTMLElement | null | undefined)what had focus beforeWhere focus goes on close (defaults to what had focus before; pass the photo that opened it, since Safari doesn't focus tapped buttons).

Keyboard

KeysAction
TabThe message list is one tab stop on the active row; the composer and header buttons are ordinary tab stops.
Arrow Up/Arrow Down, Home/End, Page Up/Page DownMove between messages.
Enter/SpaceOpen the message's actions menu.
R/EReply to, or edit (your own), the focused message.
Enter/Shift + EnterComposer: send / add a line (on touch keyboards Return adds a line).
Arrow Up in an empty composerEdit your last message.
EscapeCancel a reply or an edit.

Accessibility

  • Each row is an article named by a spoken summary (sender, text, time, delivery state); the header names the chat and presence is written in words.
  • Delivery state, reactions and typing are spoken in a polite live region; the "Jump to latest" button and composer controls have names.
  • Targets are 44 px on touch screens, text is 16 px so iOS does not zoom, and forced colors give bubbles real borders.

All exports on this page

  • ChatComposer — The message field: grows with its text, emoji picker, attachments with thumbnails, reply and edit bars, and a send button.
  • ChatThread — One conversation: header, the message log and the composer.
  • DeliveryStatus — sending (clock) → sent (✓) → delivered (✓✓) → read (✓✓, coloured), failed (!).
  • EmojiPicker — A compact emoji picker: search, category shortcuts and a grid.
  • ImageLightbox — Full-size photos in a dialog: Left / Right (and swipe) between them, a counter and a download link.
  • TypingDots — Three dots in a wave.
  • defaultChatLabels — The English ChatLabels every chat component starts from; resolveChatLabels merges a partial override over them.

When to use the chat view

  • Use it as a message thread for the main pane of a messaging app, with bubbles grouped by sender, day labels, a New messages line, replies, reactions, photos, files and delivery ticks.
  • Use it for a customer support console, where agents see typing indicators, failed messages with Retry and a message list that loads earlier messages when the reader reaches the top without losing their place.
  • Use onSend, onEdit, onDelete and onReact to connect your backend; append the new message at once with status sending so the ticks can move from sending to sent, delivered and read.
  • Skip it when you need a one-shot AI prompt and answer layout; AI chat block suits a streaming assistant, and Popover chat already wraps this view for a corner support widget.
  • Pair it with Chat list to pick conversations, Avatar for senders, and AlertDialog behavior already used for confirming delete.

Frequently asked questions

67 components pages in all: browse them on All components.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .