Tailwind CSS Order
The order utility class in Tailwind CSS allows you to control the order of flex or grid items within a container.
Tailwind Order
The order
utility class in Tailwind CSS allows you to control the order of flex or grid items within a container. With Tailwind's order class, you can easily adjust the positioning of elements within a flex or grid layout.
Applying Order
To apply the order to an element, you can use the order-{number}
utility class, where {number}
represents the desired order. The order value can be positive or negative. By default, elements have an order value of 0, which means they appear in their natural order.
<div class="flex"> <div class="bg-purple-500 order-3">Item 1</div> <div class="bg-purple-500 order-2">Item 2</div> <div class="bg-purple-500 order-1">Item 3</div></div>
Preview
Responsive Order
Tailwind CSS allows you to apply the order classes responsively at different breakpoints. To use responsive order classes, you can append the breakpoint prefix to the utility class. For example, md:order-2 applies the order-2 class starting from the medium breakpoint and above.
<div class="flex"> <div class="bg-gray-200 md:order-2">Item 1</div> <div class="bg-gray-200 order-1">Item 2</div> <div class="bg-gray-200 order-3">Item 3</div></div>
In the above example, the order of the flex items is adjusted responsively using the md:order-2 class. The first flex item (Item 1) will have an order of 2 starting from the medium breakpoint and above.
Tailwind Order Class Table
Class | Properties |
---|---|
order-1 | order: 1; |
order-2 | order: 2; |
order-3 | order: 3; |
order-4 | order: 4; |
order-5 | order: 5; |
order-6 | order: 6; |
order-7 | order: 7; |
order-8 | order: 8; |
order-9 | order: 9; |
order-10 | order: 10; |
order-11 | order: 11; |
order-12 | order: 12; |
order-first | order: -9999; |
order-last | order: 9999; |
order-none | order: 0; |
Windframe Tailwind blocks
Windframe is a drag and drop builder for rapidly building tailwind css websites and UIs