Tailwind CSS Flex wrap

The tailwind flex wrap utility class in Tailwind CSS allows you to control whether flex items should wrap or stay on a single line 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.

Setting Tailwind Flex Wrap

To set 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
---

That's it! You now have a good understanding of how to use the flex wrap utility classes in Tailwind CSS to control whether flex items should wrap or stay on a single line within a flex container.

Tailwind Flex Wrap Class Table

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

Windframe Tailwind blocks

footer

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