Performance: Why arbitrary values exist
Using arbitrary values affects CSS bundle size and rendering performance by allowing precise styles without bloating the stylesheet.
<div class="m-[4.25rem]"></div><div class="m-17"></div>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using many predefined Tailwind classes | Low | Minimal | Low | [OK] Good |
| Using many arbitrary values excessively | Low | Minimal | Medium (due to complex CSS selectors) | [!] OK |
| Using inline styles instead of arbitrary values | Low | Minimal | Low | [X] Bad (increases inline style usage) |
w-[450px].w-[450px] uses square brackets and includes units correctly.w-[450px] -> Option B<div class="w-[30rem] bg-blue-500 text-white p-4">Hello</div>
w-[30rem]bg-blue-500 sets a blue background, text-white sets white text, and p-4 adds padding.<div class="h-[100] bg-red-400">Error</div>
h-[100] but lacks units like px or rem.100 alone is invalid.rounded-[12px] and p-[1.25rem].rounded-[12px] p-[1.25rem] correctly uses brackets and includes units for both border radius and padding.rounded-[12px] p-[1.25rem] -> Option DPass the test and this pattern moves unknown