Email Compose Dialog
A batteries-included launcher that opens the Docyrus EmailComposer (wired to the messaging API) inside a dialog, seeded with recipients/subject/body.
Email Compose Dialog opens the Docyrus EmailComposer
inside a modal, fully wired to the tenant messaging API through
useDocyrusEmailComposer. Give it a client and an
optional to / cc / bcc / subject / body seed and it handles account loading, sending, and a
success/error toast.
The composer body only mounts while the dialog is open, so each open re-reads the current seeds and
the GET /v1/messaging/email/accounts query fires only when visible. On a successful send it calls
onSent(result), shows a toast, and closes.
The body editor's @ mention autocomplete is active out of the box — the underlying hook loads the
tenant's users from /v1/users by default (see the hook's mentions option to disable).
It is the component behind the inline compose action on the
EmailFormField and EmailValue renderer — pass a client to
those (directly or via useDocyrusFormView / useDocyrusDataGrid / useDocyrusDataTable) and the
action lights up automatically.
This is a Docyrus-connection component. It needs an authenticated RestApiClient to
list email accounts and send, so the preview above is informational only — wire it against your
tenant (or the playground) to see it work. Sending requires the OAuth token to carry the
Messaging.Email.Send scope.
Installation
pnpm dlx @docyrus/cli add @docyrus/ui-email-compose-dialogpnpm add @tanstack/react-query sonner @docyrus/api-clientUsage
Standalone
import { useDocyrusAuth } from '@docyrus/signin';
import { EmailComposeDialog } from '@docyrus/ui/components/email-compose-dialog';
function ContactActions({ email }: { email: string }) {
const { client } = useDocyrusAuth();
if (!client) return null;
return (
<EmailComposeDialog
client={client}
to={[email]}
subject="Following up"
onSent={result => console.log('accepted', result.accepted)} />
);
}Custom trigger
<EmailComposeDialog
client={client}
to={[email]}
trigger={<Button variant="outline">Email contact</Button>} />Automatic on fields, values, and grids
Pass a client to the email form field / value renderer (or let the Docyrus hooks thread it for you)
and the compose action appears with no extra wiring:
// Form field + value renderer
<EmailFormField field={field} form={form} client={client} />
<EmailValue field={field} value={record.email} client={client} />
// Whole form — useDocyrusFormView threads `client` into every field
const formView = useDocyrusFormView({ client, appSlug, dataSourceSlug, itemId });
// Grids — EmailCell (data grid) and EmailValue (data table) light up automatically
const grid = useDocyrusDataGrid({ client, appSlug, dataSourceSlug });API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
client | RestApiClient | — | Authenticated Docyrus REST client. Required. |
to | string[] | — | Pre-filled recipients. |
cc | string[] | — | Pre-filled Cc recipients. |
bcc | string[] | — | Pre-filled Bcc recipients. |
subject | string | — | Pre-filled subject. |
body | string | — | Pre-filled body (HTML). |
trigger | ReactNode | Ghost mail icon button | Custom element that opens the dialog. |
open | boolean | — | Controlled open state. |
onOpenChange | (open: boolean) => void | — | Open-state change handler. |
title | string | "Compose email" | Dialog title. |
disabled | boolean | false | Disables the default trigger button. |
sendAsUser | boolean | — | Send through the tenant account with the user's identity (subject to account override rules). |
slashCommands | EmailComposerSlashCommand[] | — | Developer-defined / slash commands forwarded to the composer body editor (see the composer's Slash Commands section). |
onSent | (result: DocyrusEmailSendResult) => void | — | Called after a successful send. |
className | string | — | Extra class for the default trigger button. |
Related
EmailComposer— the presentational composer this dialog mounts.useDocyrusEmailComposer— the hook that wires the composer to the messaging API.InstantMessageComposeDialog— the SMS / WhatsApp counterpart for phone fields.
DSQL Editor
A two-pane workbench for writing and running DSQL (security-scoped SQL) over Docyrus data sources, with a result grid and an embedded AI agent.
Instant Message Compose Dialog
A batteries-included launcher that opens the Docyrus InstantMessageComposer (SMS / WhatsApp) inside a dialog, seeded with recipients and body.