Tailwind CSS 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.

html
<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

Item 1
items 2
items 3

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.

html
<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

ClassProperties
order-1order: 1;
order-2order: 2;
order-3order: 3;
order-4order: 4;
order-5order: 5;
order-6order: 6;
order-7order: 7;
order-8order: 8;
order-9order: 9;
order-10order: 10;
order-11order: 11;
order-12order: 12;
order-firstorder: -9999;
order-lastorder: 9999;
order-noneorder: 0;

Windframe Tailwind blocks

Pricing

Build modern projects using Bootstrap 5 and Contrast

Trying to create components and pages for a web app or website from scratch while maintaining a modern User interface can be very tedious. This is why we created Contrast, to help drastically reduce the amount of time we spend doing that. so we can focus on building some other aspects of the project.

Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants. Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.

ad-banner