Skip to content
Twentyfirst UIHalo

Mail Composer

Forms · MailComposer, RecipientInput, RichTextEditor

View as Markdown

Writing a mail: from (a select when you may send from several addresses), To, Cc and Bcc as RecipientInput, subject, the text in the RichTextEditor, the signature with a switch, and attachments.

  • Attachments: onFiles gets the files picked on the device; attachSources adds places such as "From Drive" (your picker). Uploads show their progress; Send waits for them.
  • Draft: the whole draft goes to onChange; saved and savedAt show "Draft saved 10:42".
  • Sending: Send or ⌘/Ctrl+Enter. With onUndoSend a toast offers Undo for undoSeconds (default 10); hold the mail that long. "Send later" picks a date and time (onSchedule).
New messageDraft saved 10:42 AM
Lena Hart
Mara Ellis Head of Operations · Example Inc.
  • pricing-v3.pdf1.2 MB
  • seat-model.xlsx84 KB

Props

MailComposer

PropTypeNotes
senders?{ address: string; name?: string }[]Addresses you may send from; a select when there are several.
value?MailDraftThe draft (controlled) / initially / on every change (save it as a draft).
defaultValue?Partial<MailDraft>
onChange?(draft: MailDraft) => void
suggestions?MailRecipient[]
suggest?(typed: string) => MailRecipient[] | Promise<MailRecipient[]>
signature?ReactNodeThe signature shown under the text, with a switch to leave it out.
onSend?(draft: MailDraft) => voidSend (also ⌘/Ctrl+Enter); on only with valid recipients and no upload running.
onUndoSend?(draft: MailDraft) => voidShows "Message sent" with Undo in a toast (needs a `<Toaster/>`). Hold the mail for `undoSeconds` and drop it when this is called.
undoSeconds?numberHow long Undo stays (default 10 s).
onSchedule?(draft: MailDraft, at: Date) => void"Send later" with a date and time.
onFiles?(files: File[]) => voidFiles picked on this device (add them to `attachments` and upload).
attachSources?{ label: string; icon?: IconName; onClick: () => void }[]More places to attach from, e.g. "From Drive" (opens your picker).
onRemoveAttachment?(id: string) => void
saved?"saving" | "saved" | "error" | nullDraft state: saving, saved (at `savedAt`) or failed.
savedAt?Date
onDiscard?() => void
sending?boolean
title?stringHeading (default "New message").
placeholder?string
minHeight?number
autoFocus?boolean
footer?ReactNodeMore controls in the footer.
className?stringExtra class on the root element.
style?CSSPropertiesInline style on the root element.

RecipientInput

PropTypeNotes
labelstringRequired
hideLabel?boolean
id?string
value?MailRecipient[]The addresses (controlled) / initially / on change.
defaultValue?MailRecipient[]
onChange?(value: MailRecipient[]) => void
suggestions?MailRecipient[]Known addresses, filtered while typing.
suggest?(typed: string) => MailRecipient[] | Promise<MailRecipient[]>Or ask your server while typing (debounced).
validate?(address: string) => booleanYour own address check (default: a plain e-mail pattern).
placeholder?string
hint?string
error?string
disabled?boolean
autoFocus?boolean
className?stringExtra class on the root element.
style?CSSPropertiesInline style on the root element.

RichTextEditor

PropTypeNotes
label?ReactNode
hideLabel?booleanHide the label visually; it stays the editor's accessible name.
defaultValue?string
value?string
onChange?(html: string) => void
placeholder?string
variables?{ key: string; label: string }[]
maxLength?number
minHeight?number
footer?ReactNode
hint?ReactNode
error?ReactNode
disabled?boolean
className?stringExtra class on the root element.
style?CSSPropertiesInline style on the root element.