Dev Helpers
← Back

Spine width estimate

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

Open this example in the interactive library

Live preview

Source code

// components/SpineWidthEstimate.tsx

import { useState } from "react";

export default function SpineWidthEstimate({ pages = 28 }: { pages?: number } = {}) {
  const [caliper, set] = useState(0.1);
  return (
    <label>
      Paper thickness (mm)
      <input
        type="number"
        step=".01"
        min={0}
        value={caliper}
        onChange={(e) => set(+e.target.value)}
      />
      <output>{(Math.ceil(pages / 2) * caliper).toFixed(2)} mm spine</output>
    </label>
  );
}