Dev Helpers
← Back

Pallet capacity calculator

Import and render <PalletCapacityCalculator /> in a React project.

Open this example in the interactive library

Live preview

Source code

// components/PalletCapacityCalculator.tsx

export default function PalletCapacityCalculator({
  counts = [12, 0, 5, 18],
  target = 10,
}: { counts?: number[]; target?: number } = {}) {
  const total = counts.reduce((a, b) => a + b, 0);
  return (
    <output>
      {Math.ceil(total / Math.max(target, 1))} pallets needed at {Math.max(target, 1)}{" "}
      units each
    </output>
  );
}