affectUI › Components › Cards

Email Draft

Agent-written email for review – switch recipient and tone, edit inline, remove the attachment, send or discard with undo.

Free and open source (MIT). Install: npx shadcn@latest add https://www.affectui.com/r/email-draft.json · Import from @/components/ui/email-draft

When to use

  • Human-in-the-loop flows where an agent drafts an email and someone approves it – renewals, reminders, follow-ups
  • Inboxes or task lists of pending outreach, one card per record

When not to use

  • Writing long emails from scratch – use a full editor
  • Messages that go out without review – then a simple activity row is enough

Usage

import { EmailDraft } from "@/components/ui/email-draft";

export function RenewalReview() {
  return (
    <EmailDraft
      reference="SUB-1182"
      account="Northwind Logistics"
      amount="$8,900"
      status="Renews in 5 days"
      agent="Renewal agent"
      contacts={[{ name: "Jonas Weber", email: "jonas@northwind.io" }]}
      attachment="Renewal-quote.pdf"
      link={{ label: "Review quote", href: "/quotes/1182" }}
      onSend={(email) => api.send(email)}
    />
  );
}

Props

NameTypeDefaultDescription
referencestring"SUB-1182"Reference of the record the email is about
accountstring"Northwind Logistics"Account or company under the reference
amountstring"$8,900"Amount on the right
statusstring"Renews in 5 days"Status chip next to the reference
agentstring"Renewal agent"Who wrote the draft, shown in the footer
contactsDraftContact[]People the email can go to – the first is preselected
attachmentstring | nullFile name of the attachment; it can be removed and added back
tonesDraftTone[]Text variants { id, label, body(contact) } – Friendly, Short and Formal by default
link{ label, href }Link appended to the email text
onSend({ to, body, attachment }) => voidCalled after Send with the final email
onDiscard() => voidCalled when the draft is discarded
classNamestringExtra class on the root

Keyboard

  • ⌘ / Enter: Sends the email while editing
  • Esc: Leaves editing, or closes the recipient menu

Accessibility

  • The recipient is a button that opens a listbox; tones are toggle buttons with aria-pressed
  • The text is a plain paragraph; clicking it or the pencil swaps in a labelled text field
  • Sent and discarded states are announced as a status with an Undo button

Responsive

  • Fills its container up to 520px; on narrow screens the email address and the shortcut hint hide
  • Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"

Requirements

  • React 19

Guides