TotalsLast updated on
Last updated on
The artifact's computed amounts, evaluated by @paradoc/core.
Totals prints nothing it computes itself: each row names a def the
artifact declares as a computed field with its own expression, and
@paradoc/core evaluates it. Totals only reads the def's label and its
serializer-formatted amount, the same way a Field reads a plain one.
Preview
Installation
npx shadcn@4 add @paradoc/totalsOr, with the Paradoc CLI, which writes the namespace into components.json for you:
npx paradoc-cli add totalsInstalls to components/paradoc/totals.tsx and brings along keep-together.
Usage
import { Totals } from "@/components/paradoc/totals";<Totals rows={[{ def: "total", label: "Amount due", emphasis: true }]} />| Prop | Type | Default | Description |
|---|---|---|---|
| rows | readonly TotalRow[] | — | The computed amounts to show, in order. |
| id? | string | "totals" | Stable keep id. |
| className? | string | — | Application-owned classes replacing the block's default column layout. |
Composition
Totals needs the same Document context every other component here does,
and each row's def names a computed field the artifact declares —
subtotal, tax, total, and so on — the same convention
Field uses for a plain path, pointed instead at an
expression. It is a Keep Together, so the whole block is never split
across a page break.
Totals normally follows the Table it totals, inside
the same Section: a table of line items, then the
subtotal, tax, and grand total beneath it. A row's optional ratePath
prints a percentage field beside that row's own label — a tax rate next to
"Tax" — without a separate row for it, and emphasis marks the grand total
with a rule and bolder text. When a tenant sets an accent color, an
emphasized row's rule is one of three places it lands, alongside a titled
section's heading and an emphasized Table footer row.
The rows' sizes, and the emphasized total's, follow the document's typography token.
Variants
Single row
One emphasized def, for a document with nothing to subtotal separately.
With tax rate
ratePath prints the rate field beside the tax row's own label.
Custom label
label overrides the total def's own label.