dolfindevelopers

Receipt preview

ComponentExpensesSDK + UI

The uploaded receipt file: a PDF in a frame or the photo inline, from a short-lived signed link fetched when shown. Loading and failure states, with retry.

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

Choose your integration

Ready to connect to Dolfin. Loads data through SDK hooks, with appearance and behaviour you can customise. Requires DolfinProvider.

Loading preview…

Installation

Needs the Dolfin registry token. The CLI copies the source into your app.

Terminal
bunx --bun shadcn@4.23.0 add @dolfin/expenses-receipt-preview

Also installs: button, base-document-viewer, ui-expenses-receipt-preview.

Usage

screen.tsx
import { ReceiptPreview } from "@/components/dolfin/expenses/receipt-preview";

// Place it anywhere inside your <DolfinProvider>.
<ReceiptPreview />

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

PropTypeDescription
receiptIdstringFetch the receipt's short-lived file link.
urlstringA file link you already hold: shown as given, nothing is fetched.
loadingboolean
errorError
onRetry() => voidShows a retry button with the error.
contentTypestringThe receipt's `contentType`; PDFs render in a frame, images inline.
showOpenLinkbooleanShows an "Open in new tab" link above the file.
classNamestring

Customisation

Without editing the source, you can change:

Class names
className
Messages
base.documentViewerbase.states.retryexpenses.receipts.preview

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.

useMessagesuseReceiptFile

Files

Written to your app by the install command:

  • components/dolfin/expenses/receipt-preview.tsx 52 lines