Performance: Responsive typography scaling
This affects page load speed and rendering performance by controlling how font sizes adjust across different screen sizes without causing layout shifts.
<p class="text-[clamp(1rem,2vw,2.5rem)] md:text-[clamp(1rem,2vw,2.5rem)]">Hello World</p><p class="text-base md:text-4xl">Hello World</p>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Abrupt breakpoint font size changes | Minimal | Multiple on viewport resize | High due to layout shifts | [X] Bad |
| Fluid typography with clamp() and Tailwind | Minimal | Single on initial load | Low, smooth scaling | [OK] Good |
text-lg md:text-xl do in terms of font size?md: applies styles starting from medium screen sizes (768px and up).text-lg md:text-xltext-sm for small, text-md is not a valid class, text-lg is medium-large.lg: applies styles at large screens (1024px+). So text-sm lg:text-lg means small text on mobile, larger text on large screens.text-sm lg:text-lg -> Option Ctext-base sm:text-lg md:text-xl lg:text-2xl?text-base md:text-lg sm:text-xl but the font size is not increasing on medium screens. What is the problem?md:text-lg is overridden by sm:text-xl because sm: is smaller breakpoint but comes later.text-sm on mobile, text-base on tablets (640px+), and text-lg on desktops (1024px+). Which Tailwind class combination achieves this?text-sm default for mobile, md:text-base applies at 768px+, and lg:text-lg applies at 1024px+. This combination ensures text-base on tablets (md breakpoint) and text-lg on desktops (lg breakpoint).text-sm md:text-base lg:text-lg -> Option APass the test and this pattern moves unknown