Open this example in the interactive library
Live preview
Source code
// components/TeamEffortAllocation.tsx
import { useState } from "react";
export default function TeamEffortAllocation({ hours = 8 }: { hours?: number } = {}) {
const [people, set] = useState(2);
return (
<label>
Team size
<input
type="number"
value={people}
onChange={(e) => set(Math.max(1, +e.target.value))}
/>
<output>{(hours / people).toFixed(1)} hours per person</output>
</label>
);
}
