Dev Helpers

React / Recipe scaling

Batch weight summary

Dev Helpers · November 1, 2026

Batch weight combines quantity and unit weight. Convert all measurements to the same unit before aggregating them.

Worked example

// components/BatchWeightSummary.tsx

export default function BatchWeightSummary({
  grams = [120, 80, 50],
  servings = 2,
}: { grams?: number[]; servings?: number } = {}) {
  return (
    <p>
      Batch {grams.reduce((a, b) => a + b, 0)} g · {servings} portions
    </p>
  );
}

Implementation notes

Keep units in the labels of both inputs and outputs. A valid numeric total can still be wrong if kilograms and grams enter the same multiplication.

Try it yourself

Compare one heavy item with several lighter items of the same total weight.

Open the React example →

Editorial date November 1, 2026 · Published December 6, 2026

Related articles

Percentage meter

A percentage meter needs both a bounded visual fill and a meaningful textual value. Handle a zero denominator before dividing.

Vertical typesetting sample

Vertical typesetting changes the reading direction and available inline space. Treat the sample text as content so it remains selectable and accessible.

Square cover crop

A square image crop gives a card grid consistent geometry. The crop anchor determines whether the most important part of a photo survives.