FreeMIT LicenseFeatured

Parley — Team Chat App for React, shadcn/ui & Tailwind (Messenger UI)

A complete team chat for React and shadcn/ui: conversation list with tabs, threads with replies, reactions and Markdown, image lightbox, file uploads, voice notes, internal notes, @mentions, calls, contact and group details, profile and invites. Light and dark, phone to desktop.

by UpFork, built by Ramin ValadanComponentUpdated 26 Oct 2026

Read how it was madeBehind the build3 lessons
Watch0
Preview of Parley — Team Chat App for React, shadcn/ui & Tailwind (Messenger UI)

Code

63 files · 8 packages · 25 assets

/**
 * Pure chat actions: (data, …args) → new data. The store (store.ts) only wires them to React; tests and undo use
 * them directly. Nothing here reads the clock or the DOM: callers pass `now` and new ids in.
 */
import { firstName } from "@/lib/contacts"
import type { Attachment, Contact, Conversation, Message, MessageStatus, MuteDuration, Presence, Profile } from "./types"

export interface ChatData {
	me: Profile
	contacts: Record<string, Contact>
	conversations: Conversation[]
	/** Messages per conversation, oldest first. */
	messages: Record<string, Message[]>
	drafts: Record<string, string>
}

type Patch<T> = Partial<T> | ((value: T) => Partial<T>)

function updateConversation(data: ChatData, id: string, patch: Patch<Conversation>): ChatData {
	return {
		...data,
		conversations: data.conversations.map((c) =>
			c.id === id ? { ...c, ...(typeof patch === "function" ? patch(c) : patch) } : c
		),
	}
}

function updateMessage(data: ChatData, conversationId: string, messageId: string, patch: Patch<Message>): ChatData {
	const list = data.messages[conversationId]
	if (!list) return data
	return {
		...data,
		messages: {
			...data.messages,
			[conversationId]: list.map((m) =>
				m.id === messageId ? { ...m, ...(typeof patch === "function" ? patch(m) : patch) } : m
			),
		},
	}
}

function append(data: ChatData, conversationId: string, message: Message): ChatData {
	return {
		...data,
		messages: { ...data.messages, [conversationId]: [...(data.messages[conversationId] ?? []), message] },
	}
}

export function nameOf(data: ChatData, id: string) {
	if (id === "me") return "You"
	return data.contacts[id]?.name ?? "Someone"
}

function systemMessage(conversationId: string, id: string, text: string, now: number): Message {
	return { id, conversationId, senderId: "system", kind: "system", text, createdAt: now }
}

export interface OutgoingMessage {
	id: string
	text: string
	attachments?: Attachment[]
	replyToId?: string
	now: number
}

export function sendMessage(data: ChatData, conversationId: string, m: OutgoingMessage): ChatData {
	const message: Message = {
		id: m.id,
		conversationId,
		senderId: "me",
		kind: "text",
		text: m.text,
		attachments: m.attachments?.length ? m.attachments : undefined,
		replyToId: m.replyToId,
		createdAt: m.now,
		status: "sending",
	}
	const next = append(data, conversationId, message)
	return updateConversation({ ...next, drafts: { ...next.drafts, [conversationId]: "" } }, conversationId, {
		archived: false,
		unread: 0,
		markedUnread: false,
	})
}

export function addNote(data: ChatData, conversationId: string, m: OutgoingMessage): ChatData {
	const note: Message = {
		id: m.id,
		conversationId,
		senderId: "me",
		kind: "note",
		text: m.text,
		attachments: m.attachments?.length ? m.attachments : undefined,
		replyToId: m.replyToId,
		createdAt: m.now,
	}
	const next = append(data, conversationId, note)
	return { ...next, drafts: { ...next.drafts, [conversationId]: "" } }
}

/** An incoming message. `active` = the conversation is open and scrolled to the newest message. */
export function receiveMessage(data: ChatData, message: Message, active: boolean): ChatData {
	const next = append(data, message.conversationId, message)
	return updateConversation(next, message.conversationId, (c) => ({
		archived: c.mutedUntil ? c.archived : false,
		unread: active ? 0 : c.unread + 1,
	}))
}

export function setMessageStatus(data: ChatData, conversationId: string, messageId: string, status: MessageStatus) {
	return updateMessage(data, conversationId, messageId, { status })
}

/** Marks every message of mine in the conversation as read (the other side opened it). */
export function markMineRead(data: ChatData, conversationId: string): ChatData {
	const list = data.messages[conversationId]
	if (!list) return data
	return {
		...data,
		messages: {
			...data.messages,
			[conversationId]: list.map((m) => (m.senderId === "me" && m.kind === "text" && m.status !== "read" ? { ...m, status: "read" } : m)),
		},
	}
}

/** Toggles `userId`'s reaction. */
export function react(data: ChatData, conversationId: string, messageId: string, emoji: string, userId = "me"): ChatData {
	return updateMessage(data, conversationId, messageId, (m) => {
		const reactions = (m.reactions ?? []).map((r) => ({ ...r, userIds: [...r.userIds] }))
		const existing = reactions.find((r) => r.emoji === emoji)
		if (existing) {
			existing.userIds = existing.userIds.includes(userId)
				? existing.userIds.filter((u) => u !== userId)
				: [...existing.userIds, userId]
		} else {
			reactions.push({ emoji, userIds: [userId] })
		}
		return { reactions: reactions.filter((r) => r.userIds.length > 0) }
	})
}

export function editMessage(data: ChatData, conversationId: string, messageId: string, text: string, now: number) {
	return updateMessage(data, conversationId, messageId, (m) => (m.text === text ? {} : { text, editedAt: now }))
}

export function deleteMessage(data: ChatData, conversationId: string, messageId: string) {
	return updateMessage(data, conversationId, messageId, {
		deleted: true,
		text: "",
		attachments: undefined,
		link: undefined,
		reactions: undefined,
		pinned: false,
	})
}

export function pinMessage(data: ChatData, conversationId: string, messageId: string, pinned?: boolean) {
	return updateMessage(data, conversationId, messageId, (m) => ({ pinned: pinned ?? !m.pinned }))
}

export function forwardMessage(
	data: ChatData,
	source: Message,
	targets: Array<{ conversationId: string; id: string }>,
	now: number
): ChatData {
	let next = data
	const from = source.senderId === "me" ? data.me.name : nameOf(data, source.senderId)
	for (const target of targets) {
		next = append(next, target.conversationId, {
			id: target.id,
			conversationId: target.conversationId,
			senderId: "me",
			kind: "text",
			text: source.text,
			attachments: source.attachments?.map((a) => ({ ...a, progress: undefined })),
			link: source.link,
			forwardedFrom: from,
			createdAt: now,
			status: "sent",
		})
		next = updateConversation(next, target.conversationId, { archived: false })
	}
	return next
}

export function pinChat(data: ChatData, conversationId: string, pinned?: boolean) {
	return updateConversation(data, conversationId, (c) => ({ pinned: pinned ?? !c.pinned }))
}

const MUTE_MS: Record<Exclude<MuteDuration, "always">, number> = {
	"1h": 3600_000,
	"8h": 8 * 3600_000,
	"1w": 7 * 24 * 3600_000,
}

/** Mutes for a duration, or unmutes with `null`. */
export function muteChat(data: ChatData, conversationId: string, duration: MuteDuration | null, now: number) {
	const mutedUntil = duration === null ? 0 : duration === "always" ? Infinity : now + MUTE_MS[duration]
	return updateConversation(data, conversationId, { mutedUntil })
}

export function toggleFavourite(data: ChatData, conversationId: string, favourite?: boolean) {
	return updateConversation(data, conversationId, (c) => ({ favourite: favourite ?? !c.favourite }))
}

export function markRead(data: ChatData, conversationId: string) {
	return updateConversation(data, conversationId, { unread: 0, markedUnread: false })
}

export function markUnread(data: ChatData, conversationId: string) {
	return updateConversation(data, conversationId, (c) => ({ markedUnread: c.unread === 0 }))
}

export function archiveChat(data: ChatData, conversationId: string, archived?: boolean) {
	return updateConversation(data, conversationId, (c) => {
		const value = archived ?? !c.archived
		return { archived: value, pinned: value ? false : c.pinned }
	})
}

export function clearChat(data: ChatData, conversationId: string, systemId: string, now: number): ChatData {
	const next = updateConversation(data, conversationId, { unread: 0, markedUnread: false })
	return {
		...next,
		messages: { ...next.messages, [conversationId]: [systemMessage(conversationId, systemId, "Chat cleared", now)] },
	}
}

export function blockContact(data: ChatData, contactId: string, blocked: boolean, systemId: string, now: number) {
	const dm = data.conversations.find((c) => c.kind === "dm" && c.contactId === contactId)
	if (!dm) return data
	const name = nameOf(data, contactId)
	const next = updateConversation(data, dm.id, { blocked })
	return append(next, dm.id, systemMessage(dm.id, systemId, blocked ? `You blocked ${name}` : `You unblocked ${name}`, now))
}

/** Removes the contact's direct conversation and the contact itself. */
export function deleteContact(data: ChatData, contactId: string): ChatData {
	const dm = data.conversations.find((c) => c.kind === "dm" && c.contactId === contactId)
	const contacts = { ...data.contacts }
	delete contacts[contactId]
	const messages = { ...data.messages }
	if (dm) delete messages[dm.id]
	return {
		...data,
		contacts,
		messages,
		conversations: data.conversations
			.filter((c) => c.id !== dm?.id)
			.map((c) => (c.memberIds.includes(contactId) ? { ...c, memberIds: c.memberIds.filter((m) => m !== contactId) } : c)),
	}
}

export function leaveGroup(data: ChatData, conversationId: string): ChatData {
	const messages = { ...data.messages }
	delete messages[conversationId]
	return { ...data, messages, conversations: data.conversations.filter((c) => c.id !== conversationId) }
}

export function addMembers(data: ChatData, conversationId: string, contactIds: string[], systemId: string, now: number) {
	const conversation = data.conversations.find((c) => c.id === conversationId)
	if (!conversation) return data
	const fresh = contactIds.filter((id) => !conversation.memberIds.includes(id))
	if (!fresh.length) return data
	const next = updateConversation(data, conversationId, { memberIds: [...conversation.memberIds, ...fresh] })
	const names = fresh.map((id) => firstName(nameOf(data, id)))
	const list = names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}` : names[0]
	return append(next, conversationId, systemMessage(conversationId, systemId, `You added ${list}`, now))
}

export interface NewGroup {
	id: string
	name: string
	description?: string
	photo?: string
	memberIds: string[]
	quickReplies: string[]
	now: number
	systemIds: [string, string]
}

export function createGroup(data: ChatData, g: NewGroup): ChatData {
	const conversation: Conversation = {
		id: g.id,
		kind: "group",
		name: g.name,
		description: g.description,
		photo: g.photo,
		memberIds: ["me"],
		adminIds: ["me"],
		pinned: false,
		favourite: false,
		mutedUntil: 0,
		archived: false,
		unread: 0,
		markedUnread: false,
		quickReplies: g.quickReplies,
		createdAt: g.now,
	}
	const next: ChatData = { ...data, conversations: [conversation, ...data.conversations] }
	const created = append(next, g.id, systemMessage(g.id, g.systemIds[0], `You created the group “${g.name}”`, g.now))
	return addMembers(created, g.id, g.memberIds, g.systemIds[1], g.now)
}

/** Opens (or creates) the direct conversation with a contact; returns the data and its id. */
export function ensureDirect(data: ChatData, contactId: string, now: number, quickReplies: string[]): [ChatData, string] {
	const existing = data.conversations.find((c) => c.kind === "dm" && c.contactId === contactId)
	if (existing) return [existing.archived ? updateConversation(data, existing.id, { archived: false }) : data, existing.id]
	const conversation: Conversation = {
		id: contactId,
		kind: "dm",
		contactId,
		memberIds: ["me", contactId],
		adminIds: [],
		pinned: false,
		favourite: false,
		mutedUntil: 0,
		archived: false,
		unread: 0,
		markedUnread: false,
		quickReplies,
		createdAt: now,
	}
	return [{ ...data, conversations: [conversation, ...data.conversations], messages: { ...data.messages, [contactId]: [] } }, contactId]
}

export function updateProfile(data: ChatData, patch: Partial<Profile>): ChatData {
	return { ...data, me: { ...data.me, ...patch } }
}

export function setStatus(data: ChatData, presence: Presence): ChatData {
	return { ...data, me: { ...data.me, presence } }
}

export function setDraft(data: ChatData, conversationId: string, text: string): ChatData {
	if ((data.drafts[conversationId] ?? "") === text) return data
	return { ...data, drafts: { ...data.drafts, [conversationId]: text } }
}

export function updateAttachment(data: ChatData, conversationId: string, messageId: string, attachmentId: string, patch: Partial<Attachment>) {
	return updateMessage(data, conversationId, messageId, (m) => ({
		attachments: m.attachments?.map((a) => (a.id === attachmentId ? { ...a, ...patch } : a)),
	}))
}

export function addSystem(data: ChatData, conversationId: string, id: string, text: string, now: number) {
	return append(data, conversationId, systemMessage(conversationId, id, text, now))
}
63 files25 assets8 packages

From the workbench

Written about Parley — Team Chat App for React, shadcn/ui & Tailwind (Messenger UI)

By the developer who built it: how it works, with its real code and live preview in the text, and the lessons learned along the way.

About

A complete chat app (the dashboard's /apps/chat) built on shadcn/ui with Base UI primitives, Tailwind CSS 4, motion, sonner, zustand and the frimousse emoji picker. Light and dark, phone to wide desktop.

npm install
npm run dev      # http://localhost:5201
npm run build && npm run start   # review build on http://localhost:5200

What is in it

  • List: my avatar (opens My profile), New chat, Invite; search (/); All / Unread / Groups / Favourites with live counts; collapsible Pinned, Recent and Archived sections; rows with presence ring, smart dates, You: and receipts, typing and draft previews, Markdown in previews, pin / mute / 99+ badges; hover quick actions, right-click menu (mute 1 h / 8 h / 1 week / Always), skeletons, ↑/↓ + Enter, reorder animation.
  • Conversation: header button that opens details, presence or "last seen", member stack, search with match count, call / video call overlay, More menu (search, mute, pin, favourite, export, clear, block / leave); grouped bubbles with sender-side corners, sticky date chips, "New messages" divider, scroll-to-bottom with a count, typing bubble, reply quotes that jump to the original, reactions, hover action bar (react, reply, copy, forward, pin, more → edit / delete / copy link), long-press sheet on phones, images with lightbox, file cards with upload progress, link previews, voice notes, code blocks with copy, system lines, internal notes.
  • Composer: Reply / Internal note (dashed, lock, "Add note"), auto-growing input, Enter / Shift+Enter, bold, italic, strikethrough, code, link popover, list, emoji (20 quick + recents, search, categories, skin tones), attachments by button, drag-and-drop or paste, @mentions in groups, reply and edit bars (↑ edits my last message), per-chat drafts, quick replies (Tab takes the first).
  • Panels and dialogs: details panel on xl (sheet below), contact and group info with Media / Files / Links, My profile (avatar upload with circle crop, sections, status, custom status), Invite (chips, invalid e-mails, role, message, copy link), New chat / New group, confirmations for every destructive action, toasts with Undo, keyboard shortcut sheet (?).

Where things live

Path
components/chat/chat-layout.tsxChatLayout: panes, URL state (?c=, ?m=), shortcuts, overlays
components/chat/actions.tspure actions (sendMessage, react, muteChat, clearChat, …)
components/chat/store.tsthe zustand store (data + UI state)
components/chat/commands.tsuser commands: confirm dialogs and toasts with Undo
components/chat/data.tsthe demo conversations (dates move to "today" on load)
components/chat/demo.tsdemo realism: receipts, typing, canned replies, uploads (remove for a real backend)
lib/contacts.tsthe people, shared by every app of the dashboard
public/images/avatars/profile photos (npm run avatars, credits in CREDITS.md)
public/images/chat/image attachments (npm run media, credits in CREDITS.md)
public/emojibase/en/emoji data for the picker, self-hosted (npm run emoji)

npm run shots takes review screenshots (light and dark, 1440 → 390 px) into screenshots/.

The app needs a <Toaster /> (sonner) mounted once, as app/layout.tsx does.

Reviews and bugs

0 reviews · 0 bugs

Ship it0With fixes0Skip0· 0 reviews

0 bugs0 open0 fixed

Members who have it review it and report its bugs. Sign in

No reviews or bugs yet.

Manual installation

Without the CLI

  1. 01

    Install the packages

    npm install @base-ui/react class-variance-authority cmdk frimousse lucide-react motion sonner zustand
  2. 02

    Copy the files into your project

    • components/chat/actions.ts
    • components/chat/avatar-uploader.tsx
    • components/chat/avatars.tsx
    • components/chat/call-overlay.tsx
    • components/chat/chat-header.tsx
    • components/chat/chat-layout.tsx
    • components/chat/chat-list-item.tsx
    • components/chat/chat-list.tsx
    • components/chat/chat-scroll-area.tsx
    • components/chat/chat.css
    • components/chat/commands.ts
    • components/chat/composer.tsx
    • components/chat/conversation-view.tsx
    • components/chat/data.ts
    • components/chat/demo.ts
    • components/chat/details-panel.tsx
    • components/chat/dialogs.tsx
    • components/chat/emoji-picker.tsx
    • components/chat/empty-state.tsx
    • components/chat/format.ts
    • components/chat/hooks.ts
    • components/chat/icon-button.tsx
    • components/chat/invite-dialog.tsx
    • components/chat/lightbox.tsx
    • components/chat/link-popover.tsx
    • components/chat/markdown.tsx
    • components/chat/media.ts
    • components/chat/message-actions.tsx
    • components/chat/message-bubble.tsx
    • components/chat/message-list.tsx
    • components/chat/message-parts.tsx
    • components/chat/new-chat-dialog.tsx
    • components/chat/people-picker.tsx
    • components/chat/profile-sheet.tsx
    • components/chat/quick-replies.tsx
    • components/chat/selectors.ts
    • components/chat/store.ts
    • components/chat/styles.ts
    • components/chat/textarea-format.ts
    • components/chat/types.ts
    • components/chat/ui/alert-dialog.tsx
    • components/chat/ui/avatar.tsx
    • components/chat/ui/badge.tsx
    • components/chat/ui/button.tsx
    • components/chat/ui/collapsible.tsx
    • components/chat/ui/command.tsx
    • components/chat/ui/context-menu.tsx
    • components/chat/ui/dialog.tsx
    • components/chat/ui/dropdown-menu.tsx
    • components/chat/ui/input-group.tsx
    • components/chat/ui/input.tsx
    • components/chat/ui/kbd.tsx
    • components/chat/ui/label.tsx
    • components/chat/ui/popover.tsx
    • components/chat/ui/select.tsx
    • components/chat/ui/sheet.tsx
    • components/chat/ui/skeleton.tsx
    • components/chat/ui/slider.tsx
    • components/chat/ui/switch.tsx
    • components/chat/ui/tabs.tsx
    • components/chat/ui/textarea.tsx
    • components/chat/ui/tooltip.tsx
    • lib/contacts.ts

    The paths follow the shadcn/ui layout, with @/ as your project’s import alias.

  3. 03

    Its pictures and data files load from UpFork

    The code above points at UpFork’s copies (1.1 MB), so there’s nothing to copy. To host them yourself, use Download source: its ZIP has the files where the code expects them, and a README on the switch.

    It shows pictures with next/image, which loads only from hosts it’s told about. Add this to next.config:

    images: {
      remotePatterns: [{ protocol: "https", hostname: "upfork.dev", pathname: "/assets/**" }],
    },

Before you buy

Everything you need to know

How this component gets from the preview into your project, and what buyers ask most.

How to use it

From the preview to your project

  1. 01

    Try it in the preview

    Switch between light and dark, and resize it to phone and tablet widths, before you decide.

  2. 02

    Get it

    Free products are yours with a free account. Paid ones settle in USDT on TRON, sent straight to the wallet on your order.

  3. 03

    Install it

    Components go into your project with one shadcn command, dependencies included. Everything else downloads with a checksum.

  4. 04

    Make it yours

    It's your code now: rename it, restyle it and wire in your real data.

  5. 05

    Or hand it to your AI

    Copy the prompt and let your coding assistant place it in your project, following your conventions.

Building with an AI assistant?

Copy a ready-made prompt with the code, its dependencies and a demo, and your assistant can put it in place for you.

Copy AI prompt

Selling your own work?

Get approved once, then publish components, templates and mobile components, paid in USDT straight to your own wallet.