Invoice preview
The invoice as the customer sees it: its PDF, the email a draft's send would deliver, and the pay page once issued, as tabs; tabs that do not apply yet stay disabled with the reason.
Component: A piece you place inside your own screens: a table, a form, a card or a dialog. You decide the layout around it. Pages vs components
Ready to connect to Dolfin. Loads data through SDK hooks, with appearance and behaviour you can customise. Requires DolfinProvider.
Installation
Needs the Dolfin registry token. The CLI copies the source into your app.
bunx --bun shadcn@4.23.0 add @dolfin/ar-invoice-pdf-previewAlso installs: tabs, base-document-viewer, base-info-hint, base-states, ui-ar-invoice-pdf-preview.
Usage
import { InvoicePdfPreview } from "@/components/dolfin/ar/invoice-pdf-preview";
// Place it anywhere inside your <DolfinProvider>.
<InvoicePdfPreview />Renders inside DolfinProvider (set it up once). By default it loads its own data through the SDK. Supplied-data examples show how to override that behavior.
API reference
| Prop | Type | Description |
|---|---|---|
invoiceId | string | Loads the invoice, its PDF and (for a draft, once its tab opens) the email a send would deliver. |
invoice | { id?: string; organisationId?: string; customerId?: string; documentNumber?: null | string; currency: string; issueDate?: string; dueDate?:… | Your own invoice: the preview then makes no request. |
pdfUrl | string | The PDF to show (an object URL or a link). |
loading | boolean | The PDF is still being made. |
error | Error | |
onRetry | () => void | |
email | { subject: string; previewText: string; greetingLine: string; openingBodyMarkdown: string; openingBodyHtml: string; htmlBody: string; textBo… | Shows the Email tab with this email (a draft's send would deliver it). |
emailLoading | boolean | |
emailError | Error | |
onEmailRetry | () => void | |
emailDisabledReason | string | Shows the Email tab disabled, with why beside it. |
pdfOnly | boolean | Hides the email and pay page tabs, leaving the PDF alone. |
className | string |
Customisation
Without editing the source, you can change:
- Class names
className- Messages
ar.invoice.previewbase.documentViewerbase.infoHint.moreAboutbase.states.retrycore.errors
Or edit the installed file directly: it is your code. See theming for colours and fonts.
Hooks
The SDK hooks this component uses. Use them directly from @dolfinai/react to build your own version.
useInvoiceuseInvoiceEmailPreviewuseInvoicePdfuseInvoiceSettingsuseMessagesFiles
Written to your app by the install command:
components/dolfin/ar/invoice-pdf-preview.tsx105 lines