Flexbox & Grid

Order

Utilities for controlling the order of flex and grid items.

Quick reference

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;

Show all classes

Basic usage

Ordering flex and grid items

Use order-{order} to render flex and grid items in a different order than they appear in the DOM.

Order - 图1


1. <div class="flex justify-between ...">
2. <div class="order-last">01</div>
3. <div>02</div>
4. <div>03</div>
5. </div>

Using negative values

To use a negative order value, prefix the class name with a dash to convert it to a negative value.


1. <div class="-order-1">
2. <!-- ... -->
3. </div>


Applying conditionally

Hover, focus, and other states

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:order-last to only apply the order-last utility on hover.


1. <div class="order-first hover:order-last">
2. <!-- ... -->
3. </div>

For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

Breakpoints and media queries

You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:order-last to apply the order-last utility at only medium screen sizes and above.


1. <div class="order-first md:order-last">
2. <!-- ... -->
3. </div>

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.


Using custom values

Customizing your theme

By default, Tailwind provides utilities for order-first, order-last, order-none, and an order-{number} utility for the numbers 1 through 12. You can customize these values by editing theme.order or theme.extend.order in your tailwind.config.js file.

tailwind.config.js


1. module.exports = {
2. theme: {
3. extend: {
4. order: {
5. '13': '13'
6. }
7. }
8. }
9. }

Learn more about customizing the default theme in the theme customization documentation.

Arbitrary values

If you need to use a one-off order value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.


1. <div class="order-[13]">
2. <!-- ... -->
3. </div>

Learn more about arbitrary value support in the arbitrary values documentation.