Check out our free templates made with AI and polished to perfection in Windframe

Get now
Last updated: 11 August 2025

Tailwind CSS Flex wrap

The tailwind flex wrap utility class in Tailwind CSS allows you to control whether flex items stay on a single line or wrap onto multiple lines within a flex container.


Tailwind Flex Wrap

The tailwind flex wrap utility class in Tailwind CSS allows you to control whether flex items stay on a single line or wrap onto multiple lines within a flex container. It provides a set of classes that enable you to easily specify the wrapping behavior, allowing you to create flexible and responsive layouts.

How to apply Tailwind Flex Wrap

To apply the tailwind flex wrap behavior of a flex container, you can use the flex class in combination with one of the following classes: To apply the tailwind flex wrap behavior of a flex container, you can use the flex class in combination with one of the following classes:

  • flex-wrap: This allows flex items to wrap onto multiple lines if needed.

  • flex-wrap-reverse: This allows flex items to wrap onto multiple lines in reverse order if needed.

  • flex-nowrap: This prevents flex items from wrapping and keeps them on a single line.

Tailwind Flex-wrap

Tailwind flex wrap class allows flex items to wrap onto multiple lines if needed.

html
<div class="flex flex-wrap....">
<div class="flex-1">A</div>
<div class="flex-1">B</div>
<div class="flex-1">C</div>
</div>

Preview

A

B

C

Tailwind Flex Wrap Reverse

Tailwind flex wrap reverse class allows flex items to wrap onto multiple lines in reverse order if needed

html
<div class="flex flex-wrap-reverse....">
<div class="flex....">A</div>
<div class="flex...">B</div>
<div class="flex...">C</div>
</div>

Preview

A

B

C

Tailwind Flex-Nowrap

Tailwind flex nowrap class prevents flex items from wrapping and keeps them on a single line

html
<div class="flex flex-nowrap....">
<div class="flex-none...">A</div>
<div class="flex-none...">B</div>
<div class="flex-none...">C</div>
</div>

Preview

A

B

C

Responsive Behavior

You can control flex wrapping per breakpoint:

html
<div class="flex flex-nowrap md:flex-wrap lg:flex-wrap-reverse">...</div>

Preview

Items 1

Items 2

Items 3

items 4

Mobile: no wrapping

Tablet: wrap normally

Desktop: reverse wrap

Interaction State Use (hover/focus)

It’s rare but possible to change wrapping on interaction:

html
<div class="flex flex-nowrap hover:flex-wrap">...</div>

Preview

Items 1

Items 2

Items 3

items 4

Useful for preview or expanded layouts on hover.

Arbitrary Value Usage

Tailwind doesn’t have arbitrary values for flex-wrap because it’s an enumerated property (fixed keywords only). You must use one of the three available utilities unless you extend in tailwind.config.js.

Customization in tailwind.config.js

If you need custom wrapping behavior (e.g., a class name alias), extend flexWrap in your config:

js
module.exports = {
theme: {
extend: {
flexWrap: {
no: "nowrap",
yes: "wrap",
"reverse-order": "wrap-reverse",
},
},
},
};

Now you can use flex-no or flex-yes in your HTML.

Real UI Component Example

Responsive Card Grid

html
<div class="flex flex-wrap gap-6 p-6 bg-gray-50">
<div class="flex-1 min-w-[250px] bg-white shadow-md p-4 rounded-lg">
<h2 class="font-semibold text-lg">Card 1</h2>
<p>Short description here.</p>
</div>
<div class="flex-1 min-w-[250px] bg-white shadow-md p-4 rounded-lg">
<h2 class="font-semibold text-lg">Card 2</h2>
<p>Short description here.</p>
</div>
<div class="flex-1 min-w-[250px] bg-white shadow-md p-4 rounded-lg">
<h2 class="font-semibold text-lg">Card 3</h2>
<p>Short description here.</p>
</div>
</div>

Preview

Card 1

Short description here.

Card 2

Short description here.

Card 3

Short description here.

Why flex-wrap? The cards wrap neatly on smaller screens without overflowing.

Best Practices for Devs/Designers

  • Use flex-wrap for content that must adapt to smaller viewports (e.g., tag lists, card layouts).

  • Pair with gap-x and gap-y utilities for consistent spacing.

  • Avoid flex-wrap-reverse unless the reversed order is intentional for UX.

  • Combine with flex-basis (basis-*) for predictable wrapping points.

Accessibility Notes

  • Wrapping doesn’t directly impact accessibility, but improper wrapping can hurt readability if related content is split unexpectedly.

  • Ensure wrapped layouts still preserve logical reading order (important for screen readers).

  • Test at different breakpoints so interactive elements remain visible and usable.

Tailwind Flex Wrap Class Table

ClassProperties
flex-wrapflex-wrap: wrap
flex-wrap-reverseflex-wrap: wrap-reverse;
flex-nowrapflex-wrap: nowrap;

✨ What's Next?

Windframe Tailwind blocks

footer

Windframe is an AI visual editor for rapidly building stunning web UIs & websites

Start building stunning web UIs & websites!

Build from scratch or select prebuilt tailwind templates