Performance: Flex basis and sizing
This affects how quickly the browser calculates layout and paints flexible items, impacting page load and responsiveness.
<div class="flex"> <div class="basis-1/2">Content</div> <div class="basis-1/2">Content</div> </div>
<div class="flex"> <div class="flex-auto">Content</div> <div class="flex-auto">Content</div> </div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| flex-auto (flex-basis: auto) | Measures content size | Multiple reflows on content change | Higher paint cost due to layout thrashing | [X] Bad |
| basis-1/2 (fixed flex-basis) | No content measurement needed | Single reflow | Lower paint cost, stable layout | [OK] Good |
basis-1/3 do in a flex container?basis-1/3 in Tailwind64 equals 16rem (4rem * 16).basis-64 to set basis to 16rem, no 'rem' suffix used.<div class="flex w-96"> <div class="basis-1/4 bg-blue-500">Box 1</div> <div class="basis-1/2 bg-red-500">Box 2</div> <div class="basis-1/4 bg-green-500">Box 3</div> </div>
Box 2 inside the 24rem wide container?basis-1/2, so initial size is half of 24rem = 12rem.<div class="flex"> <div class="basis-2/3">Item 1</div> <div class="basis-1/2">Item 2</div> </div>
basis-1/4 for 25% and basis-1/2 for 50% widths.grow for flex-grow:1 and [flex-grow:2] for flex-grow:2.grow, middle item gets [flex-grow:2] to grow twice as fast.basis-1/4 grow, basis-1/2 [flex-grow:2], basis-1/4 grow -> Option Agrow and [flex-grow:2] with basis fractions [OK]Pass the test and this pattern moves unknown