Dev Helpers
← Back

Labour estimate with contingency

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

Open this example in the interactive library

Live preview

Source code

// components/LabourEstimateWithContingency.tsx

import { useState } from "react";

export default function LabourEstimateWithContingency({
  hours = 8,
  rate = 60,
}: { hours?: number; rate?: number } = {}) {
  const [extra, set] = useState(10);
  return (
    <label>
      Contingency %
      <input
        type="range"
        max={30}
        value={extra}
        onChange={(e) => set(+e.target.value)}
      />
      <output>{(hours * rate * (1 + extra / 100)).toFixed(2)}</output>
    </label>
  );
}