Performance: Peer modifier (sibling state reaction)
MEDIUM IMPACT
This affects how CSS selectors trigger style recalculations and repaints when sibling elements change state.
<button class="peer focus:outline-none">Click me</button> <div class="peer-focus:bg-blue-500">Box</div>
<button id="btn">Click me</button> <div id="box">Box</div> <script> document.getElementById('btn').addEventListener('click', () => { document.getElementById('box').classList.toggle('bg-blue-500'); }); </script>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| JavaScript toggling sibling class | 1 event listener, 2 DOM updates | Multiple reflows per toggle | Multiple paints | [X] Bad |
| Tailwind peer modifier CSS | No extra DOM ops | Single reflow on state change | Single paint | [OK] Good |