Performance: Odd and even row styling
MEDIUM IMPACT
This affects the rendering speed and visual stability of tables or lists by applying styles conditionally to rows.
<table class="w-full"> <tr class="odd:bg-white even:bg-gray-100">...</tr> <tr class="odd:bg-white even:bg-gray-100">...</tr> <tr class="odd:bg-white even:bg-gray-100">...</tr> <tr class="odd:bg-white even:bg-gray-100">...</tr> </table>
<table> <tr class="bg-white">...</tr> <tr class="bg-gray-100">...</tr> <tr class="bg-white">...</tr> <tr class="bg-gray-100">...</tr> </table>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Manual class on each row | Increased DOM nodes and attributes | Multiple reflows if classes change | Higher paint cost due to more DOM | [X] Bad |
| Tailwind odd: and even: variants | Minimal DOM changes, styles via CSS | No extra reflows | Lower paint cost, efficient style application | [OK] Good |