Open this example in the interactive library
Live preview
Source code
// components/OvertimeBreakdown.tsx
export default function OvertimeBreakdown({
hours = 8,
rate = 60,
}: { hours?: number; rate?: number } = {}) {
const regular = Math.min(hours, 8);
const extra = Math.max(0, hours - 8);
return (
<p>
{regular} regular + {extra} overtime hours ={" "}
{(regular * rate + extra * rate * 1.5).toFixed(2)}
</p>
);
}
