Sum Check

Sum Check is a copy-paste React component that stops total doesn't add up before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/sum-check
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 3 extra npm packages
  • A11y guidance in docs

StopsTotal doesn't add up

Was this component page useful?

How do I install Sum Check?

pnpm dlx shadcn@latest add @bollard/sum-check

The files land in your project. They're yours to edit.

How do I use Sum Check in React?

sum-check-usage.tsx
import { checkSum, SumCheck, type SumCheckKind, type SumRow } from "@/components/ui/sum-check"

<SumCheck
  key={tab}
  rows={example.rows}
  kind={example.kind}
  total={total}
  roundedTo={example.roundedTo}
  format={example.kind === "percent" ? undefined : money}
  totalLabel={example.kind === "total" ? "Stated subtotal" : undefined}
  onSuspectSelect={flash}
  onUseSum={(sum) => setTotals((t) => ({ ...t, [tab]: sum }))}
/>

What input mistakes does Sum Check catch?

  • Totals that don't equal the sum of rows
  • Gaps divisible by 9 (transposed digits)
  • A shifted decimal point, flipped sign or wrong side
  • A row left out or counted twice
  • Gaps explained by rounding when decimals are set

What props does Sum Check accept?

SumCheck props
PropTypeDefault
kindSumCheckKind"total"
total

The stated total ("total"), or the target for "percent" (default 100).

number—
roundedTo

Decimal places the row values were rounded to. Set it and small gaps are reported as rounding.

number—
rows* (required)

Rows to add, and the stated total or debit/credit rows.

SumRow[]—
format

Formats amounts. Defaults to the row precision; percent adds "%".

(value: number) => string—
onUseSum

Offer a one-tap "use the row sum" fix for a wrong stated total.

(sum: number) => void—
onSuspectSelect

Called when a likely culprit is picked, so the table can scroll to and highlight that row.

(id: string) => void—
sumLabel

Label of the computed sum.

string"Sum of rows"
totalLabel

Label of the stated total.

stringkind === "percent" ? "Should add up to" : "Stated total"
debitsLabel

Label of the debits sum.

string"Debits"
creditsLabel

Label of the credits sum.

string"Credits"
okText

Templates: `{gap}`, `{sum}`, `{total}`, `{higher}`, `{tolerance}`, `{count}`, `{decimals}` are filled in.

stringkind === "balance" ? "Debits equal credits." : "Adds up."
offText

Shown when the total is off. `{diff}` is filled in.

stringkind === "balance" ? "Off by {gap}: {higher} are higher."…
roundingText

Shown when the gap is only rounding.

string"Off by {gap}, which rounding alone explains: {count} fig…
ninesText

Hint when the gap points to transposed digits.

string"The gap divides by 9, a typical sign of two swapped digi…
suspectsLabel

Accessible label of the suspects list.

string"Likely cause"
useSumLabel

Label of the use-the-sum fix.

string"Use {sum}"
wholeNumbersText

The `{decimals}` in `roundingText`: whole numbers, or `{places}` decimal places.

string"whole numbers"
decimalPlacesText

Explains decimal places used for rounding.

string"{places} decimal places"
reasons

Text for each kind of suspected slip.

Partial<Record<SumSuspect["reason"], string>>—

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Sum Check accessible?

  • Status in a polite live region; focus moves to it after a fix
  • Suspects list has an aria-label; each suspect is a button
  • Rolling figures respect reduced motion

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

  • Suggests single-row slips only; several errors at once may not be explained
  • Rounding tolerance depends on the decimals you set

What expensive mistakes does Sum Check stop?

Total doesn't add up

Also known as

total · sum · reconciliation · invoice · ledger · spreadsheet · accounting · tally

Field type

What dependencies does Sum Check require?

Sum Check facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameSum Check
Registry identifier@bollard/sum-check
Install commandnpx shadcn@latest add @bollard/sum-check
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react, @number-flow/react, motion
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Sum Check

How does Sum Check prevent financial transaction errors?

Sum Check prevents total doesn't add up. Blocks Totals that don't equal the sum of rows, Gaps divisible by 9 (transposed digits), A shifted decimal point, flipped sign or wrong side, A row left out or counted twice, Gaps explained by rounding when decimals are set before processing. Limitation: apply idempotency keys for sum-check.

How do I install sum-check with shadcn?

Run `npx shadcn@latest add @bollard/sum-check`. Sources added: registry/default/sum-check/sum-check.tsx. Package requirements: lucide-react, @number-flow/react, motion.

What props customize Sum Check?

Sum Check accepts `kind`, `total`, `roundedTo`, `rows`, `format`. Configures total, sum, reconciliation behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of sum-check?

Suggests single-row slips only; several errors at once may not be explained. Rounding tolerance depends on the decimals you set Server requirement: backend verification for sum-check.

How does Sum Check meet accessibility guidelines?

Status in a polite live region; focus moves to it after a fix. Suspects list has an aria-label; each suspect is a button. Rolling figures respect reduced motion. Minimizes errors: total mismatch, sum is wrong.

Which components pair with Sum Check?