FreeMIT License

Mailroom — Email Client & Inbox UI for React, shadcn/ui and Tailwind

A complete email client for React and shadcn/ui: three resizable panes, folders and labels, threaded conversations, a rich-text compose window with recipient chips and attachments, an inline reply, snooze, multi-select with bulk actions, undo toasts, keyboard shortcuts, phone…

by UpFork, built by Ramin ValadanComponentUpdated 5 Nov 2026

Read how it was madeBehind the build6 lessons
Watch0
Preview of Mailroom — Email Client & Inbox UI for React, shadcn/ui and Tailwind

Code

33 files · 10 packages · 15 assets

"use client"

import * as React from "react"
import { createPortal } from "react-dom"
import { AnimatePresence, motion } from "motion/react"
import {
  Maximize2Icon,
  Minimize2Icon,
  MinusIcon,
  MoreVerticalIcon,
  PaperclipIcon,
  SaveIcon,
  SendIcon,
  Trash2Icon,
  UploadIcon,
  XIcon,
} from "lucide-react"
import { toast } from "sonner"
import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
} from "@/components/ui/alert-dialog"
import { Button } from "@/components/ui/button"
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"
import { cn } from "@/lib/utils"
import { Editor, type RichTextHandle } from "./editor"
import { attachmentKind, fileSize, isEmail } from "./format"
import { useReducedMotionPref } from "./hooks"
import { modKey } from "./keys"
import { useMail, useMailActions, useMailContext } from "./mail-context"
import { ActionButton, Hint } from "./parts"
import { RecipientInput } from "./recipient-input"
import type { ComposeMode, ComposeSession, Draft } from "./types"

/** Mounts the Compose window while a session is open. */
export function ComposeHost() {
  const compose = useMail((s) => s.compose)
  const mounted = React.useSyncExternalStore(
    () => () => {},
    () => true,
    () => false,
  )
  if (!mounted) return null
  return createPortal(<AnimatePresence>{compose && <ComposeWindow key={compose.key} session={compose} />}</AnimatePresence>, document.body)
}

const AUTOSAVE_MS = 1500

/**
 * A floating window docked bottom-right (expanded, minimized to a bar, or full screen), and a full-screen sheet
 * on phones: recipient chips, Cc/Bcc, subject, rich text, attachments by picker or drop, autosave to Drafts,
 * Send with Undo.
 */
function ComposeWindow({ session }: { session: ComposeSession }) {
  const actions = useMailActions()
  const { config } = useMailContext()
  const reduce = useReducedMotionPref()
  const phone = config.layout === "one"
  const mode: ComposeMode = phone && session.mode !== "minimized" ? "fullscreen" : session.mode
  const initial = session.initial

  const [to, setTo] = React.useState(initial.to)
  const [cc, setCc] = React.useState(initial.cc)
  const [bcc, setBcc] = React.useState(initial.bcc)
  const [showCc, setShowCc] = React.useState(initial.cc.length > 0)
  const [showBcc, setShowBcc] = React.useState(initial.bcc.length > 0)
  const [subject, setSubject] = React.useState(initial.subject)
  const [html, setHtml] = React.useState(initial.html)
  const [files, setFiles] = React.useState(initial.attachments)
  const [dragging, setDragging] = React.useState(false)
  const [confirm, setConfirm] = React.useState(false)
  const [savedAt, setSavedAt] = React.useState<number | null>(null)
  const draftId = React.useRef(session.draftId)
  const editor = React.useRef<RichTextHandle>(null)
  const fileInput = React.useRef<HTMLInputElement>(null)
  const dragDepth = React.useRef(0)

  const draft = (): Draft => ({ to, cc, bcc, subject, html: editor.current?.getHTML() ?? html, attachments: files })
  const hasContent = to.length + cc.length + bcc.length + files.length > 0 || !!subject.trim() || !!html
  const recipients = [...to, ...cc, ...bcc]
  const valid = recipients.length > 0 && recipients.every(isEmail)
  const title = subject.trim() ? subject.trim() : "New Message"

  // Autosave into Drafts a moment after the last change. Once the window is sent, discarded or closed it saves
  // nothing more, even while it animates out.
  const first = React.useRef(true)
  const done = React.useRef(false)
  const autosave = React.useRef<ReturnType<typeof setTimeout>>(undefined)
  const finish = () => {
    done.current = true
    clearTimeout(autosave.current)
  }
  React.useEffect(() => {
    if (first.current) {
      first.current = false
      return
    }
    if (!hasContent || done.current) return
    autosave.current = setTimeout(() => {
      if (done.current) return
      draftId.current = actions.saveDraft(draft(), draftId.current)
      setSavedAt(Date.now())
    }, AUTOSAVE_MS)
    return () => clearTimeout(autosave.current)
    // Runs when the content changes; draft() reads the same values.
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [to, cc, bcc, subject, html, files])

  const setMode = (next: ComposeMode) => actions.setComposeMode(next)

  const sent = React.useRef(false)
  const send = () => {
    if (!valid || sent.current) return
    sent.current = true
    finish()
    const message = draft()
    const savedAs = draftId.current
    const { undo } = actions.send(message, savedAs)
    config.onSend?.(message)
    actions.closeCompose()
    toast("Message sent", {
      duration: 5000,
      action: {
        label: "Undo",
        onClick: () => {
          // Undo puts the autosaved draft back too: reopen that same draft, not a copy of it.
          undo()
          actions.openCompose(message, savedAs)
          toast("Sending undone")
        },
      },
    })
  }

  const saveNow = () => {
    draftId.current = actions.saveDraft(draft(), draftId.current)
    setSavedAt(Date.now())
    toast("Draft saved")
  }

  const close = () => {
    finish()
    // Closing keeps what was written as a draft, like any mail client.
    if (hasContent) {
      draftId.current = actions.saveDraft(draft(), draftId.current)
      toast("Draft saved", { description: "Find it in Drafts." })
    }
    actions.closeCompose()
  }

  const discard = () => {
    if (hasContent) setConfirm(true)
    else actions.closeCompose()
  }

  const discardNow = () => {
    finish()
    const id = draftId.current
    if (id) actions.change([id], () => null)
    actions.closeCompose()
    setConfirm(false)
    toast("Draft discarded")
  }

  const addFiles = (list: FileList | null) => {
    if (!list?.length) return
    // Copy now: the input is cleared right after, which empties the live FileList.
    const picked = [...list]
    setFiles((current) => [
      ...current,
      ...picked.map((f) => ({
        id: `${f.name}-${f.size}-${f.lastModified}`,
        name: f.name,
        size: f.size,
        kind: attachmentKind(f.name, f.type),
        url: URL.createObjectURL(f),
      })),
    ])
  }

  const onKeyDown = (event: React.KeyboardEvent) => {
    // The editor handles its own ⌘↵ and marks the event as handled.
    if (event.defaultPrevented) return
    if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
      event.preventDefault()
      send()
    }
    if (event.key === "Escape" && mode === "fullscreen" && !phone) {
      event.preventDefault()
      setMode("expanded")
    }
  }

  const transition = { duration: reduce ? 0 : 0.2, ease: [0.2, 0, 0, 1] as const }
  const windowRef = React.useRef<HTMLDivElement>(null)
  useInertBehind(windowRef, mode === "fullscreen")

  if (mode === "minimized")
    return (
      <motion.div
        role="dialog"
        aria-label={`Compose Mail — ${title}, minimized`}
        initial={{ opacity: 0, y: 16 }}
        animate={{ opacity: 1, y: 0 }}
        exit={{ opacity: 0, y: 16 }}
        transition={transition}
        className="fixed right-4 bottom-0 z-50 w-[min(20rem,calc(100vw-2rem))] overflow-hidden rounded-t-xl border border-b-0 bg-popover text-popover-foreground shadow-2xl"
      >
        <div className="flex h-11 items-center gap-1 pr-1.5 pl-1">
          <button
            type="button"
            onClick={() => setMode("expanded")}
            className="flex h-9 min-w-0 flex-1 items-center rounded-md px-2.5 text-left text-sm font-medium outline-none hover:bg-accent/60 focus-visible:ring-2 focus-visible:ring-ring"
          >
            <span className="truncate">
              Compose Mail <span className="text-muted-foreground">— {title}</span>
            </span>
          </button>
          <ActionButton
            label="Expand"
            icon={Maximize2Icon}
            size="icon-xs"
            className="size-7"
            tooltipSide="top"
            onClick={() => setMode("expanded")}
          />
          <ActionButton label="Close" icon={XIcon} size="icon-xs" className="size-7" tooltipSide="top" onClick={close} />
        </div>
      </motion.div>
    )

  const full = mode === "fullscreen"

  return (
    <>
      {full && !phone && (
        <motion.div
          aria-hidden
          initial={{ opacity: 0 }}
          animate={{ opacity: 1 }}
          exit={{ opacity: 0 }}
          transition={transition}
          className="fixed inset-0 z-50 bg-black/40 backdrop-blur-[2px]"
          onClick={() => setMode("expanded")}
        />
      )}
      <motion.div
        ref={windowRef}
        role="dialog"
        aria-modal={mode === "fullscreen" || undefined}
        aria-labelledby={`compose-title-${session.key}`}
        initial={reduce ? { opacity: 0 } : { opacity: 0, y: 24, scale: 0.98 }}
        animate={{ opacity: 1, y: 0, scale: 1 }}
        exit={reduce ? { opacity: 0 } : { opacity: 0, y: 24, scale: 0.98 }}
        transition={transition}
        onKeyDown={onKeyDown}
        onDragEnter={(e) => {
          if (![...e.dataTransfer.types].includes("Files")) return
          dragDepth.current++
          setDragging(true)
        }}
        onDragOver={(e) => e.preventDefault()}
        onDragLeave={() => {
          dragDepth.current = Math.max(0, dragDepth.current - 1)
          if (dragDepth.current === 0) setDragging(false)
        }}
        onDrop={(e) => {
          e.preventDefault()
          dragDepth.current = 0
          setDragging(false)
          addFiles(e.dataTransfer.files)
        }}
        className={cn(
          "fixed z-50 flex flex-col overflow-hidden bg-popover text-popover-foreground",
          // Phones: 40 px tap targets, and 16 px text so iOS doesn't zoom into fields.
          phone &&
            "[&_.ProseMirror]:text-base [&_button:is([data-slot=button],[data-slot=tooltip-trigger]):not([data-hit])]:min-h-10 [&_button:is([data-slot=button],[data-slot=tooltip-trigger]):not([data-hit])]:min-w-10 [&_input]:text-base [&_label]:text-[15px]",
          phone
            ? "inset-0"
            : full
              ? "inset-x-[max(1.5rem,calc((100vw-60rem)/2))] inset-y-[max(1.5rem,6vh)] rounded-xl border shadow-2xl"
              : "right-4 bottom-0 h-[min(620px,calc(100dvh-2rem))] w-[min(560px,calc(100vw-2rem))] rounded-t-xl border border-b-0 shadow-2xl",
        )}
      >
        {/* Header: title, minimize, full screen, close. Never scrolls away. */}
        <div className="flex h-11 shrink-0 items-center gap-1 border-b bg-muted/40 pr-1.5 pl-4">
          <h2 id={`compose-title-${session.key}`} className="min-w-0 flex-1 truncate text-sm font-medium">
            Compose Mail <span className="text-muted-foreground">— {title}</span>
          </h2>
          {!phone && (
            <>
              <ActionButton
                label="Minimize"
                icon={MinusIcon}
                size="icon-xs"
                className="size-7"
                tooltipSide="top"
                onClick={() => setMode("minimized")}
              />
              <ActionButton
                label={full ? "Exit full screen" : "Full screen"}
                icon={full ? Minimize2Icon : Maximize2Icon}
                size="icon-xs"
                className="size-7"
                tooltipSide="top"
                onClick={() => setMode(full ? "expanded" : "fullscreen")}
              />
            </>
          )}
          <ActionButton label="Close" icon={XIcon} size="icon-xs" className="size-7" tooltipSide="top" onClick={close} />
        </div>

        {/* Fields */}
        <div className="shrink-0 divide-y border-b px-4">
          <RecipientInput
            id={`compose-to-${session.key}`}
            label="To"
            value={to}
            onChange={setTo}
            placeholder="Recipients"
            autoFocus={to.length === 0}
            trailing={
              <span className="ml-auto flex shrink-0 items-center text-sm">
                <CcToggle label="Cc" shown={showCc} onShow={() => setShowCc(true)} large={phone} />
                <span className="text-muted-foreground/50">|</span>
                <CcToggle label="Bcc" shown={showBcc} onShow={() => setShowBcc(true)} large={phone} />
              </span>
            }
          />
          {showCc && (
            <RecipientInput
              id={`compose-cc-${session.key}`}
              label="Cc"
              value={cc}
              onChange={setCc}
              placeholder="Carbon copy recipients"
              autoFocus
            />
          )}
          {showBcc && (
            <RecipientInput
              id={`compose-bcc-${session.key}`}
              label="Bcc"
              value={bcc}
              onChange={setBcc}
              placeholder="Blind carbon copy recipients"
              autoFocus
            />
          )}
          <div className="flex min-h-10 items-center gap-1">
            <label htmlFor={`compose-subject-${session.key}`} className="w-14 shrink-0 text-sm text-muted-foreground">
              Subject
            </label>
            <input
              data-field
              id={`compose-subject-${session.key}`}
              value={subject}
              onChange={(e) => setSubject(e.target.value)}
              placeholder="Email subject"
              autoComplete="off"
              autoFocus={to.length > 0 && !subject}
              className={cn("min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground", phone ? "h-11" : "h-9")}
            />
          </div>
        </div>

        {/* Body: the only part that scrolls, so the header and footer stay put on short screens. */}
        <Editor
          ref={editor}
          initialHTML={initial.html}
          placeholder="Write your message…"
          ariaLabel="Message body"
          toolbar="full"
          toolbarPosition="top"
          autoFocus={to.length > 0 && !!subject}
          onChange={(value, empty) => setHtml(empty ? "" : value)}
          onSubmit={send}
          className="min-h-0 flex-1 [&>[role=toolbar]]:shrink-0 [&>[role=toolbar]]:border-b [&>[role=toolbar]]:px-3 [&>[role=toolbar]]:py-1"
          contentClassName="min-h-0 flex-1 overflow-y-auto px-4 py-3"
        />

        {files.length > 0 && (
          <ul className="flex max-h-24 shrink-0 flex-wrap gap-1.5 overflow-y-auto border-t px-4 py-2.5" aria-label="Attachments">
            {files.map((f) => (
              <li
                key={f.id}
                className="inline-flex h-7 max-w-full items-center gap-1.5 rounded-full bg-muted pr-1 pl-2.5 text-xs ring-1 ring-border ring-inset"
              >
                <PaperclipIcon className="size-3 text-muted-foreground" />
                <span className="max-w-44 truncate font-medium">{f.name}</span>
                <span className="font-mono text-muted-foreground tabular-nums">{fileSize(f.size)}</span>
                <button
                  type="button"
                  aria-label={`Remove ${f.name}`}
                  onClick={() => setFiles((list) => list.filter((x) => x.id !== f.id))}
                  className="flex size-5 items-center justify-center rounded-full text-muted-foreground outline-none hover:bg-foreground/10 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring"
                >
                  <XIcon className="size-3" />
                </button>
              </li>
            ))}
          </ul>
        )}

        {/* Footer */}
        <div className="flex h-14 shrink-0 items-center gap-1 border-t px-3">
          <Tooltip>
            <TooltipTrigger asChild>
              <span tabIndex={valid ? -1 : 0} className="rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring">
                <Button onClick={send} disabled={!valid} className="gap-2">
                  <SendIcon />
                  Send
                </Button>
              </span>
            </TooltipTrigger>
            <TooltipContent side="top">
              <Hint
                label={valid ? "Send" : recipients.length ? "Fix the addresses in red first" : "Add a recipient first"}
                keys={valid ? `${modKey()} ↵` : undefined}
              />
            </TooltipContent>
          </Tooltip>
          <ActionButton
            label="Attach files"
            icon={PaperclipIcon}
            tooltipSide="top"
            onClick={() => fileInput.current?.click()}
            className="ml-1"
          />
          <span aria-live="polite" className="ml-2 hidden truncate text-xs text-muted-foreground sm:inline">
            {savedAt ? "Draft saved" : ""}
          </span>
          <div className="ml-auto flex items-center gap-0.5">
            <DropdownMenu>
              <Tooltip>
                <TooltipTrigger asChild>
                  <DropdownMenuTrigger asChild>
                    <Button
                      variant="ghost"
                      size="icon-sm"
                      aria-label="More options"
                      className="text-muted-foreground hover:text-foreground"
                    >
                      <MoreVerticalIcon />
                    </Button>
                  </DropdownMenuTrigger>
                </TooltipTrigger>
                <TooltipContent side="top">More options</TooltipContent>
              </Tooltip>
              <DropdownMenuContent align="end" side="top" className="w-48">
                <DropdownMenuItem disabled={!hasContent} onSelect={saveNow}>
                  <SaveIcon />
                  Save draft
                </DropdownMenuItem>
                {!phone && (
                  <DropdownMenuItem onSelect={() => setMode("minimized")}>
                    <MinusIcon />
                    Minimize
                  </DropdownMenuItem>
                )}
                <DropdownMenuItem onSelect={() => fileInput.current?.click()}>
                  <PaperclipIcon />
                  Attach files
                </DropdownMenuItem>
                <DropdownMenuSeparator />
                <DropdownMenuItem variant="destructive" onSelect={discard}>
                  <Trash2Icon />
                  Discard
                </DropdownMenuItem>
              </DropdownMenuContent>
            </DropdownMenu>
            <ActionButton label="Discard" icon={Trash2Icon} tooltipSide="top" onClick={discard} />
          </div>
        </div>

        <input
          ref={fileInput}
          type="file"
          multiple
          hidden
          onChange={(e) => {
            addFiles(e.target.files)
            e.target.value = ""
          }}
        />

        {dragging && (
          <div className="pointer-events-none absolute inset-2 z-10 flex flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed border-ring bg-popover/90 text-sm font-medium backdrop-blur-sm">
            <UploadIcon className="size-6 text-muted-foreground" />
            Drop files to attach
          </div>
        )}
      </motion.div>

      <AlertDialog open={confirm} onOpenChange={setConfirm}>
        <AlertDialogContent>
          <AlertDialogHeader>
            <AlertDialogTitle>Discard this message?</AlertDialogTitle>
            <AlertDialogDescription>
              What you’ve written, its recipients and its attachments will be deleted. This can’t be undone.
            </AlertDialogDescription>
          </AlertDialogHeader>
          <AlertDialogFooter>
            <AlertDialogCancel>Keep editing</AlertDialogCancel>
            <AlertDialogAction onClick={discardNow} className="bg-destructive text-white hover:bg-destructive/90 dark:bg-destructive/60">
              Discard
            </AlertDialogAction>
          </AlertDialogFooter>
        </AlertDialogContent>
      </AlertDialog>
    </>
  )
}

function CcToggle({ label, shown, onShow, large }: { label: string; shown: boolean; onShow: () => void; large?: boolean }) {
  return (
    <button
      type="button"
      onClick={onShow}
      disabled={shown}
      aria-label={`Add ${label} recipients`}
      className={cn(
        "rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40",
        large ? "h-10 min-w-10 px-2" : "px-1.5 py-1",
      )}
    >
      {label}
    </button>
  )
}

/**
 * While a window covers the page, everything else in <body> is inert (no focus, no clicks, hidden from screen
 * readers), except toasts, so Undo stays reachable.
 */
function useInertBehind(ref: React.RefObject<HTMLElement | null>, active: boolean) {
  React.useEffect(() => {
    const el = ref.current
    if (!active || !el) return
    const own = [...document.body.children].find((child) => child.contains(el))
    const others = [...document.body.children].filter(
      (child): child is HTMLElement =>
        child !== own &&
        child instanceof HTMLElement &&
        !child.inert &&
        !child.querySelector("[data-sonner-toaster]") &&
        child.tagName !== "SCRIPT",
    )
    others.forEach((child) => (child.inert = true))
    return () => others.forEach((child) => (child.inert = false))
  }, [ref, active])
}
33 files15 assets10 packages

From the workbench

Written about Mailroom — Email Client & Inbox UI for React, shadcn/ui and Tailwind

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 premium mail client you drop into a dashboard: folders and labels on the left, the conversation list in the middle, the thread on the right, in three resizable panes that remember their sizes. Search highlights what it finds, rows animate out when you archive them, every action can be undone, and the whole thing runs from the keyboard. The Compose window floats bottom-right like Gmail's, with recipient chips, rich text, attachments and autosave. Tablets get two panes, phones one screen at a time with swipes and a full-screen composer. It uses only shadcn/ui's theme tokens, so it looks finished in light and dark and takes on your theme.

Built from the brief in prompt/component/mail-upgrade-prompt.md (a redesign of an admin template's Mail page), written from scratch.

Next.js 16 (App Router), React 19, TypeScript strict, Tailwind CSS 4, shadcn/ui (Radix), react-resizable-panels, sonner, TipTap 3, motion, zustand, cmdk, react-day-picker, lucide icons, Geist and Geist Mono.

Run it

pnpm install
pnpm dev                    # http://localhost:3000
pnpm build && pnpm start    # production

The demo page is the mail client filling the window, with a light / system / dark switch. Press ? for the shortcuts. The address bar follows the view (?folder=sent, ?label=social, ?id=code-review), so views can be linked and Back works.

Use it

import { Mail } from "@/components/mail"

export default function MailPage() {
  return (
    <div className="h-[calc(100dvh-12rem)]">
      <Mail urlState />
    </div>
  )
}

<Mail> fills its parent, so give the parent a height. It picks its layout from its own width, not the window's, so it works inside any dashboard shell: three panes from 900 px, two from 640 px, one below.

PropDefaultWhat it does
datathe demo mailboxYour mailbox: { me, people, labels, threads } (see types.ts)
defaultFolder"inbox"The folder to open first (the address bar wins when urlState is on)
defaultThreadId—The conversation open at first, by thread id
urlStatefalseMirror ?folder, ?label and ?id in the address bar
shortcutstrueGmail-style single-key shortcuts
toastertrueMount a sonner <Toaster />; turn off if your layout already has one
loadingDelay320How long the list shows its skeleton on first load and folder changes (0 = never)
storageKey"mail"Where pane sizes are kept in localStorage
onSend(draft)—Called when a message is sent, to hand it to your backend
onReply(thread, mode, html)—Called when a reply or forward is sent
className—Classes for the root

All state lives in one zustand store made per <Mail> (store.ts): the actions (change with Undo snapshots, send, reply, saveDraft, addLabel, wakeSnoozed…) are pure functions over the threads, and every count is derived from the data, never stored. Swap createMailData() for your own data loader and call your API from onSend / onReply, or wrap store.actions to persist changes.

What's in it

  • Folders Inbox, Snoozed, Drafts, Sent, Spam, Trash, Archive with live counts, and labels in the five label colours (a collapsible section, New label with a name and a colour). The pane collapses to an icon rail with tooltips when dragged narrow.
  • List with All mail / Unread (a fixed badge), debounced search over sender, address, subject and body with the matches highlighted, four sort orders in a radio menu, sticky date groups, an unread dot, hover quick actions (Archive, Trash, Read/Unread, Star), a checkbox on the avatar, Shift+click ranges, a bulk bar, a right-click menu, attachment and thread-count chips, label dots with names on hover, rows that animate out, a loading skeleton, and a separate empty state for an empty folder, no results, nothing unread and nothing selected.
  • Toolbar fitted to the folder (Inbox, Snoozed, Drafts, Sent, Spam, Trash, Archive each get their own actions), tooltips with shortcuts, Manage labels with search, Snooze with presets and a date picker, previous / next with "3 of 10", and a ⋮ menu with Mark as unread, Star, Archive, Spam, Trash, Print and Copy link.
  • Thread with label pills, an avatar stack, the full date on hover, a sender card (photo, Copy email, New message), earlier messages folded into one pill, foldable message cards, quoted text behind •••, attachment cards with a download button, and your own messages on a quieter surface.
  • Reply box that opens from a one-line pill into Reply / Reply all / Forward with formatting, attachments, Mute this thread, a "Saved" draft indicator and ⌘↵ / Ctrl+↵.
  • Compose docked bottom-right (expanded, minimized, full screen), recipient chips with contact suggestions and red invalid addresses, Cc and Bcc, TipTap rich text (bold, italic, underline, lists, links, images), attachments by picker or drag and drop, autosave into Drafts, Discard with confirmation, Send with Undo. Opening a draft opens it here, filled in.
  • Undo on every move, archive, delete, spam, label, snooze and send, through sonner toasts.
  • Keyboard: J / K, Enter / O, Esc, E, #, !, S, U, L, H, X, R, A, F, C, /, G I, G S, G D and ? for the cheat sheet; none of them fire while you type.
  • Phones: one screen at a time, the thread slides in with Back, swipe left to archive and right to mark read, long press to select, a Compose button that opens a full-screen sheet, 40 px tap targets and 16 px text in fields so iOS doesn't zoom.

Accessibility

Real buttons with names, a roving tab stop in the list (↑ ↓ Home End), focus rings from --ring, labelled switches and fields, live announcements for counts, inert behind the full-screen composer, and reduced motion respected everywhere. axe-core (WCAG 2.2 AA) reports no issues on the main screens in either theme. One detail: shadcn's muted-foreground on muted is 4.3 : 1, just under AA, so muted text on muted or accent surfaces uses the foreground at 60 % instead (TEXT_ON_MUTED in parts.tsx): same palette, 5 : 1.

Checks

pnpm test          # Vitest: store, Undo snapshots, send/draft/reply, snooze, search, grouping, dates, parsing
pnpm lint          # ESLint (Next's config, React Compiler rules)
pnpm typecheck
node scripts/e2e.mjs [url]          # 108 click-through checks in Chrome (the brief's checklist, phone and tablet)
node scripts/a11y.mjs [url]         # axe-core on 7 screens × light and dark
pnpm shots [url] [scene…]           # screenshots in .review/ at 1440, 1024, 768 and 390 px, light and dark

Files

components/mail/
  mail.tsx              <Mail>: store, layouts by width, dialogs, toaster
  store.ts              the zustand store and its pure thread operations (Undo snapshots)
  selectors.ts          counts, views, search, sorting, date groups, highlights
  data.ts               the demo mailbox (dates relative to now)
  mail-sidebar.tsx      folders, labels, New label, the icon rail
  mail-list.tsx         header, tabs, search, sort, bulk bar, groups, skeleton, empty states
  mail-list-item.tsx    a row: avatar/checkbox, quick actions, chips, swipe, long press
  mail-toolbar.tsx      the folder-aware toolbar
  thread-view.tsx       the reading pane, earlier messages, draft preview, no-selection state
  message-card.tsx      a message, its body (paragraphs, lists, quotes) and attachments
  inline-reply.tsx      the reply box
  compose-window.tsx    the Compose window
  rich-text.tsx         TipTap and its toolbar (its own chunk, preloaded while idle; editor.tsx loads it)
  recipient-input.tsx   address chips with suggestions
  label-picker.tsx      Manage labels
  snooze-menu.tsx       Snooze presets (+ snooze-calendar.tsx, loaded when the date picker opens)
  sender-card.tsx       the hover card (a tap-to-open card on touch screens)
  shortcuts.tsx         the keyboard shortcuts and the cheat sheet
  use-thread-actions.ts every action with its toast and Undo
  url-state.ts          the address bar sync
components/ui/          the shadcn/ui components it uses, unchanged
public/images/avatars/  the photos (CREDITS.md), public/files/ the demo attachments
scripts/                fetch-avatars, attachments, e2e, a11y, screenshots

Re-skinning

Everything is drawn from shadcn's tokens (background, foreground, muted, accent, border, ring, primary, destructive, sidebar) plus the five label hues in parts.tsx (LABEL_STYLES). Change your theme and the mail follows; there are no hard-coded colours in the components. Times and counts use font-mono (Geist Mono in a default shadcn project).

Departures from the brief

  • Avatars use shadcn's Avatar (a plain <img> with explicit width and height, lazy, with the initials fallback delayed so it never flashes) instead of next/image, so the component installs in any React project.
  • Organisation senders were renamed so the product carries no third-party trademarks: "Amazon Deals" → Cartly Deals, "LinkedIn" → ProCircle, and the spam sender is the Inheritance Claims Office as the brief asked.
  • Label views list every conversation with the label outside Spam and Trash (as Gmail does), so Updates counts 5 and Promotions 2 (the archived Server Maintenance Notice and June newsletter carry those labels).
  • A Snoozed folder was added so snoozed conversations have somewhere to wait; they come back to the Inbox unread.
  • The star is drawn in the foreground colour, not yellow, because the palette is frozen.
  • Responsive breakpoints follow the component's own width (900 / 640 px), so it behaves the same inside a dashboard.
  • Closing Compose keeps what you wrote as a draft (as mail clients do); Discard deletes it after asking.

Credits

Photos: Unsplash, listed in public/images/avatars/CREDITS.md. The names, addresses and messages are invented. Icons: lucide. UI primitives: shadcn/ui (MIT).

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 @tiptap/extension-image @tiptap/extensions @tiptap/react @tiptap/starter-kit cmdk lucide-react motion react-resizable-panels sonner zustand
  2. 02

    Add the shadcn/ui components it uses

    npx shadcn@latest add alert-dialog avatar button calendar checkbox command context-menu dialog dropdown-menu hover-card input kbd popover resizable scroll-area separator sheet skeleton sonner switch tooltip
  3. 03

    Copy the files into your project

    • components/mail/compose-window.tsx
    • components/mail/data.ts
    • components/mail/editor.tsx
    • components/mail/empty-state.tsx
    • components/mail/format.ts
    • components/mail/hooks.ts
    • components/mail/index.ts
    • components/mail/inline-reply.tsx
    • components/mail/keys.ts
    • components/mail/label-picker.tsx
    • components/mail/mail-avatar.tsx
    • components/mail/mail-context.tsx
    • components/mail/mail-list-item.tsx
    • components/mail/mail-list.tsx
    • components/mail/mail-sidebar.tsx
    • components/mail/mail-toolbar.tsx
    • components/mail/mail.tsx
    • components/mail/message-card.tsx
    • components/mail/parts.tsx
    • components/mail/recipient-input.tsx
    • components/mail/rich-text.tsx
    • components/mail/selectors.ts
    • components/mail/sender-card.tsx
    • components/mail/shortcuts.tsx
    • components/mail/snooze-calendar.tsx
    • components/mail/snooze-menu.tsx
    • components/mail/store.ts
    • components/mail/thread-menu.tsx
    • components/mail/thread-utils.ts
    • components/mail/thread-view.tsx
    • components/mail/types.ts
    • components/mail/url-state.ts
    • components/mail/use-thread-actions.ts

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

  4. 04

    Its pictures load from UpFork

    The code above points at UpFork’s copies (115 KB), 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.

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.