React Chat App Template
A complete React chat app template: the chat list and the open chat side by side, stacking into list then chat on narrow screens.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/chat-app.jsonChats
Arrow keys move between chats, Enter opens one, Shift+F10 shows its actions.
Pick a chat
Choose a conversation from the list to read and reply.
ChatApp
Messenger
Open chats, send messages (replies arrive with typing and read receipts), pin or archive from a row's menu, and open the info panel from a chat's header. Narrow your window (or open this on a phone) to see the stacked layout.
Chats
Arrow keys move between chats, Enter opens one, Shift+F10 shows its actions.
Riya Sharma
Online
Up and Down arrows move between messages. Enter shows actions, R replies, E edits your own message.
import { useState } from "react";
import { ChatApp } from "@/components/sheenui/blocks/chat-app";
import { type ChatConversation, type ChatConversationAction, type ChatDraft, type ChatMessage, type ChatParticipant } from "@/components/sheenui/chat/types";
// Package build (after the first npm release, or a packed tarball): import { ChatApp, type ChatConversation, type ChatConversationAction, type ChatDraft, type ChatMessage, type ChatParticipant } from "@sheenui/theme";
// Your data layer: replace these with real data and handlers.
declare const chats: ChatConversation[];
declare const people: ChatParticipant[];
declare const messagesById: Record<string, ChatMessage[]>;
declare const cursors: Record<string, string | null>;
declare function loadOlder(chatId: string): void;
declare const api: {
send(chatId: string, draft: ChatDraft): void;
edit(messageId: string, text: string): void;
delete(messageId: string): void;
react(messageId: string, emoji: string, add: boolean): void;
markRead(chatId: string): void;
updateChat(chatId: string, action: ChatConversationAction): void;
block(personId: string): void;
};
export function Example() {
// Keep the open chat in the URL (?chat=c-riya) so it can be linked to.
const [chatId, setChatId] = useState<string | undefined>(() => new URLSearchParams(location.search).get("chat") ?? undefined);
return (
<ChatApp
conversations={chats}
participants={people}
currentUserId="me"
messages={messagesById}
selectedId={chatId}
onSelectedIdChange={(id) => setChatId(id ?? undefined)}
hasOlder={(id) => cursors[id] !== null}
onLoadOlder={(id) => loadOlder(id)}
onSend={(id, draft) => api.send(id, draft)}
onEdit={(id, messageId, text) => api.edit(messageId, text)}
onDelete={(id, message) => api.delete(message.id)}
onReact={(id, message, emoji, add) => api.react(message.id, emoji, add)}
onRead={(id) => api.markRead(id)}
onConversationAction={(chat, action) => api.updateChat(chat.id, action)}
onBlock={(person) => api.block(person.id)}
className="h-[44rem]"
/>
);
}Files to copy
29 folders · 49 files · 4 packages
- From
theme/src/ blocks/chat-app.tsxcomponents/chat/{chat-thread.tsx, conversation-list.tsx, chat-parts.tsx, composer.tsx, emoji-picker.tsx, emoji.ts, format.ts, hooks.ts, icons.tsx, labels.ts, message-parts.tsx, message-row.tsx, toolbar-store.ts, types.ts}components/alert-dialog/components/avatar/components/button/components/chat/conversation-list/components/chat/thread/components/context-menu/components/description-list/components/dialog/components/drawer/components/empty-state/components/file-upload/file-utils.tscomponents/input/components/kbd/components/menu/components/popover/components/segmented/components/side-drawer/{icons.tsx, side-drawer.tsx}components/side-drawer/parts/{body.tsx, content.tsx, header.tsx, model.ts, resize.tsx}components/skeleton/components/spinner/components/status-icons/components/switch/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-control-shell.tsx, field-size.ts, form.ts, glide-highlight.tsx, heading.ts, ime.ts, initials.ts, math.ts, modal-flag.ts, modal-tab-trap.ts, motion-props.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-app.jsonRegistry item: chat-app. The styles need the Tailwind v4 glass UI setup.- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Props
ChatLabels keys and English defaults (140)
Keyboard
Accessibility
- The list and the chat are labeled regions. Focus is managed on every pane change: opening a chat on a phone moves it to the chat's name, going back returns it to the row, and a keyboard open on a wide layout lands in the composer.
- New messages and typing are announced politely (aria-live); message status (sending, sent, delivered, read, failed) is written text, not color alone, and presence is written in words.
- The info panel is a side drawer (a modal dialog with a focus trap); swipe and hover actions all have keyboard and menu equivalents, so nothing is gesture-only.
- Reduced motion makes the pane slide a jump; reduced transparency makes the glass panes solid; the message area never uses blur, so scrolling stays fast.
When to use the chat app
- Use ChatApp as a messenger UI for a messaging screen in a marketplace or support tool, where a conversation list sits beside the open chat on wide containers and stacks on narrow ones.
- Use it for a team inbox with direct messages and groups, wiring onSend, onEdit, onDelete, onReact and onRetry to your backend while you hold the messages map in state.
- Use it when contact info matters, since opening a chat's info drawer shows avatar, about, phone, email, members, shared photos, and mute and block or leave actions.
- Skip it when you only need a floating help bubble on a marketing page; ChatWidget is lighter, and AiChat fits a person talking to a model rather than to other people.
- Pair it with ConversationList and ChatThread when you want a custom layout from the same parts, and with EmptyState and SideDrawer for screens around the chat.
Frequently asked questions
Related pages
20 blocks pages in all: browse them on All blocks.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .