Totals summary
Subtotal, discounts, tax by rate, total, amount paid and balance due.
import { TotalsSummary, computeTotals } from "@forgeron/ui";- Total excluding tax
- €2,200.00
- Tax 5.5 %
- on €500.00€27.50
- Tax 20 %
- on €1,700.00€340.00
- Total
- €2,567.50
import { TotalsSummary, type LineItem } from "@forgeron/ui";
const lines: LineItem[] = [
{ id: "a", description: "Workshop", quantity: 2, unitPrice: 85000, taxRate: 20 },
{ id: "b", description: "Booklets", quantity: 40, unitPrice: 1250, taxRate: 5.5 },
];
export default function Default() {
return (
<div style={{ width: 320 }}>
<TotalsSummary lines={lines} currency="EUR" locale="en" />
</div>
);
}- Subtotal
- €2,200.00
- Discounts
- -€296.50
- Total excluding tax
- €1,903.50
- Tax 5.5 %
- on €450.00€24.75
- Tax 20 %
- on €1,453.50€290.70
- Total
- €2,218.95
- Amount paid
- -€500.00
- Balance due
- €1,718.95
Due on 1 December 2026.
import { TotalsSummary, computeTotals, type LineItem } from "@forgeron/ui";
const lines: LineItem[] = [
{ id: "a", description: "Workshop", quantity: 2, unitPrice: 85000, taxRate: 20, discount: 5 },
{ id: "b", description: "Booklets", quantity: 40, unitPrice: 1250, taxRate: 5.5 },
];
export default function PaidAndDiscount() {
const totals = computeTotals(lines, { discount: { percent: 10 }, paid: 50000 });
return (
<div style={{ width: 340 }}>
<TotalsSummary totals={totals} currency="EUR" locale="en" footer="Due on 1 December 2026." />
</div>
);
}- Total
- €126.50
- Including tax Tax 5.5 %
- €1.95
- Including tax Tax 20 %
- €14.83
import { TotalsSummary, type LineItem } from "@forgeron/ui";
const lines: LineItem[] = [
{ id: "a", description: "Coffee beans", quantity: 3, unitPrice: 1250, taxRate: 5.5 },
{ id: "b", description: "Grinder", quantity: 1, unitPrice: 8900, taxRate: 20 },
];
export default function TaxIncluded() {
return (
<div style={{ width: 320 }}>
<TotalsSummary lines={lines} currency="EUR" locale="en" pricesIncludeTax taxMode="line" />
</div>
);
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
totals | Totals | — | From `computeTotals(lines, options)`. Without it, `lines` are totalled here. |
lines | LineItem[] | — | Used when `totals` is not given. |
taxMode | "rate" | "line" | "rate" | Tax worked out once per rate on the sum of its lines, or per line then added. |
pricesIncludeTax | boolean | false | The unit prices contain the tax: it is the part of the total, not an addition. |
discount | { percent?, amount? } | — | A discount on the whole document, shared between the lines so the tax stays right. |
paid | number | — | Already paid, in minor units. |
currency | string | — | An ISO 4217 code (`EUR`, `USD`, `JPY`): every amount is in its minor units. |
locale | string | — | A BCP 47 tag for the numbers and the symbol; the device's by default. |
labels | Partial<TotalsLabels> | — | The words of the rows: subtotal, discounts, net, tax, total, paid, due. |
taxLabel | (rate) => string | — | The name of a tax line. |
alwaysShowDue | boolean | false | Writes paid and due even at zero. |
footer | ReactNode | — | Under the rows: a note, a pay button. |
className | string | — | Extra classes. |