Performance: Focus-within variant
MEDIUM IMPACT
This affects the browser's style recalculation and paint when an element or its children receive focus.
<div class="focus-within:border-blue-500">
<input />
</div><div class="group"> <input class="group-focus-within:border-blue-500" /> </div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using focus-within on container | Minimal, only parent and focused child | 1 reflow on focus change | Low paint cost | [OK] Good |
| Using focus-within on many nested elements | High, many style recalculations | Multiple reflows on focus change | Higher paint cost | [X] Bad |