Performance: Order and self-alignment
This affects how quickly the browser can arrange and align flex or grid items during layout and paint.
<div class="flex"> <div class="self-start">Item 1</div> <div class="self-center">Item 2</div> <div class="self-end">Item 3</div> </div>
<div class="flex"> <div class="order-3 self-start">Item 1</div> <div class="order-1 self-center">Item 2</div> <div class="order-2 self-end">Item 3</div> </div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using many order values with self-alignment | Low | Multiple reflows per order change | Medium due to layout shifts | [X] Bad |
| Using only self-alignment without order changes | Low | Single reflow | Low paint cost | [OK] Good |
order utility in Tailwind CSS do?orderorder utility changes the visual order of flex items without changing their order in the HTML code.order.order-first sets the item to appear before all others visually.order-last places the item last, order-1 and order-0 set numeric order but order-first is the special class for first position.<div class="flex"> <div class="order-2">A</div> <div class="order-1">B</div> <div class="order-3">C</div> </div>
self-end aligns the single item to the end of the cross axis (vertical in a row flex container).items-end aligns all items, but self-end targets only one item.order-last to make the second item appear last visually.self-center to align that item vertically center without affecting others.items-start and items-center affect all items, not just one. order-3 is numeric but order-last is clearer for last position.Pass the test and this pattern moves unknown