Open this example in the interactive library
Live preview
Source code
// components/LeapYearExplainer.tsx
export default function LeapYearExplainer({
day = "2028-02-29",
}: { day?: string } = {}) {
const year = Number(day.slice(0, 4));
const leap = year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0);
return (
<p>
{year} has {leap ? 366 : 365} days.
</p>
);
}
