Open this example in the interactive library
Live preview
Source code
// components/TileCutEstimator.tsx
import { useState } from "react";
export default function TileCutEstimator({
width = 12,
height = 8,
}: { width?: number; height?: number } = {}) {
const [size, set] = useState(4);
return (
<label>
Tile side
<input
type="number"
min={1}
value={size}
onChange={(e) => set(Math.max(1, +e.target.value))}
/>
<output>
{Math.ceil(width / size) * Math.ceil(height / size)} tiles before cuts
</output>
</label>
);
}
