×

Tailwind CSS Flex Direction

CSS flexbox is an important element for frontend development. CSS has four directions, therefore in tailwind CSS, all of the properties are covered in class form. It's a front-end development alternative to the CSS flex-direction Property.

Note: You must include the flex class in your element before the flex-direction class to activate the flex-direction.

Flex Direction

The various flex direction are as follows:

  • flex-row
  • flex-row-reverse
  • flex-col
  • flex-col-reverse

flex-row

It aligns the row in the same direction as the text. Flex-direction is set to a row by default. It's used to indicate that the item's text direction is normal. It causes the item to follow the standard text line direction.

Syntax:

<element class="flex flex-row"> Contents... </element>

Example

The code is as follows:

<!DOCTYPE html>
<head>
    <title>flex-row Class in Tailwind</title>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
<body class="text-center">
    <h1 class="text-red-600 text-5xl font-bold">
        Tutorial and Example
    </h1>
    <b>flex-row Class - Tailwind CSS </b>
    <div id="main" class="flex flex-row justify-evenly">
        <div class="bg-red-900 w-24 h-12">1</div>
        <div class="bg-red-800 w-24 h-12">2</div>
        <div class="bg-red-700 w-24 h-12">3</div>
        <div class="bg-red-600 w-24 h-12">4</div>
        <div class="bg-red-500 w-24 h-12">5</div>
        <div class="bg-red-400 w-24 h-12">6</div>
    </div>
</body>
</html>

Output:

Tailwind CSS Flex Direction

flex-row-reverse

The flex-row-reverse class is used to follow the text oppositely. As can be seen in the Output, it creates flex pieces in reverse order, exactly the opposite of text orientation.

Syntax

<element class="flex flex-row-reverse"> Contents... </element>

Example

The code is as follows:

<!DOCTYPE html>
<head>
    <title>flex-row-reverse Class of Tailwind </title>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
<body class="text-center">
    <h1 class="text-red-600 text-5xl font-bold">
        Tutorial and Example
    </h1>
    <b>flex-row-reverse Class - Tailwind CSS </b>
    <div id="main" class="flex flex-row-reverse justify-evenly">
        <div class="bg-red-900 w-24 h-12">1</div>
        <div class="bg-red-800 w-24 h-12">2</div>
        <div class="bg-red-700 w-24 h-12">3</div>
        <div class="bg-red-600 w-24 h-12">4</div>
        <div class="bg-red-500 w-24 h-12">5</div>
        <div class="bg-red-400 w-24 h-12">6</div>
    </div>
</body>
</html>

Output:

Tailwind CSS Flex Direction

flex-col

This option arranges the row as a column in the same way that text does, but from top to bottom. It is used to indicate that the item's top to bottom direction is typical. As we can see in the result, it causes the object to follow the regular top to bottom orientation.

Syntax:

<element class="flex flex-col"> Contents... </element>

Example

The code is as follows:

<!DOCTYPE html>
<head>
    <title>flex-col Class of Tailwind </title>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
<body class="text-center">
    <h1 class="text-red-600 text-5xl font-bold">
        Tutorial and Example
    </h1>
    <b>flex-col Class - Tailwind CSS </b>
    <div id="main" class="flex flex-col gap-y-2">
        <div class="bg-red-900 w-30 h-12">1</div>
        <div class="bg-red-800 w-30 h-12">2</div>
        <div class="bg-red-700 w-30 h-12">3</div>
        <div class="bg-red-600 w-30 h-12">4</div>
        <div class="bg-red-500 w-30 h-12">5</div>
        <div class="bg-red-400 w-30 h-12">6</div>
    </div>
</body>
</html>

Output:

Tailwind CSS Flex Direction

flex-col-reverse

It makes the row into a column in the same way as row-reverse bottom to top does. It's used to indicate that the item's bottom to top direction is typical. It causes the item to follow the regular bottom to top orientation.

Syntax:

<element class="flex flex-col-reverse"> Contents... </element>

Example

The code is as follows:

<!DOCTYPE html>
<head>
    <title>flex-col-reverse Class of Tailwind </title>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
<body class="text-center">
    <h1 class="text-red-600 text-5xl font-bold">
        Tutorial and Example
    </h1>
    <b>flex-col-reverse Class - Tailwind CSS </b>
    <div id="main" class="flex flex-col-reverse gap-y-2">
        <div class="bg-red-900 w-30 h-12">1</div>
        <div class="bg-red-800 w-30 h-12">2</div>
        <div class="bg-red-700 w-30 h-12">3</div>
        <div class="bg-red-600 w-30 h-12">4</div>
        <div class="bg-red-500 w-30 h-12">5</div>
        <div class="bg-red-400 w-30 h-12">6</div>
    </div>
</body>
</html>

Output:

Tailwind CSS Flex Direction

Related Topics

Tailwind CSS Overflow

The overflow class acknowledges more than one value in Tailwind CSS. It is an option in contrast to the CSS Overflow property. This overflow is for controlling how element content...

9 minutes read.

Tailwind CSS Object Fit

It acknowledges more than one value in tailwind CSS. Every one of its properties is covered as in class form. It is the option in contrast to the CSS object-fit...

4 minutes read.

Tailwind CSS Clear

This class acknowledges more than one worth in tailwind CSS. Every one of the properties is canvassed as in class form. It is an option in contrast to the CSS...

5 minutes read.

Tailwind CSS Align Self

This class accepts a wide range of values. It's a replacement for the CSS Align Self attribute. This class is used to control how a flex or grid item is...

4 minutes read.

Tailwind CSS Justify Items

It is a replacement for the CSS justify-items attribute. This class is used to regulate the alignment of grid objects along their inline axis. Justify Item It is classified as: justify-items-auto justify-items-start justify-items-end justify-items-center justify-items-stretch justify-items-auto The justify-items-auto class...

4 minutes read.

Tailwind CSS Align Items

In tailwind CSS, this class accepts a wide range of values. It's a replacement for the CSS Align Items attribute. This class is used to align things within the flexible...

5 minutes read.

Tailwind CSS Grid Template Columns

In tailwind CSS, this class accepts multiple values, and all of the properties are covered in class form. It's the CSS grid-template-columns property's replacement. It's used to specify the number...

2 minutes read.

Tailwind CSS Flex Wrap

CSS flexbox is an important component for frontend development. It is a front-end development alternative to the CSS flex-wrap Property. Note: You must include the flex class in your element before...

4 minutes read.

Tailwind CSS Margin

The margin class accepts a large number of values, and all of the properties are covered in the same way they are in the class form. It's a replacement for...

6 minutes read.

Tailwind CSS Min-Width

In tailwind CSS, this class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS min-width property. This...

1 minute read.

Tailwind CSS Flex Shrink

CSS flexbox is an important element for frontend development. There are two flex-shrink options in Tailwind CSS, and all properties are covered in class form. For quick front-end development, it's...

3 minutes read.

Tailwind CSS Visibility

In tailwind CSS, this class accepts two values. It's a replacement for the CSS visibility property. This class specifies whether an element in a web document is visible or not,...

2 minutes read.

Tailwind CSS Grid Auto Flow

In tailwind CSS, this class accepts multiple values, and all of the properties are covered in class form. It is a CSS alternative. The grid-auto-flow property is used in Tailwind...

4 minutes read.

Tailwind CSS Installation

Here, we will discuss the installation method of Tailwind CSS using two strategies discussed as follows: Strategy 1: Install Tailwind through npm Step 1: npm init - y Step 2: npm install tailwindcss Step...

2 minutes read.

Tailwind CSS Place Content

This class accepts a wide range of values. It's a replacement for the CSS Place Content property. This class is used to manage how information is justified while still being...

5 minutes read.

Tailwind CSS Opacity

This class accepts a lot of value, and all of the properties are covered in class form. We can change the opacity of any element by using this class. The...

1 minute read.

Tailwind CSS Flex Grow

CSS flexbox is an important element for frontend development; there are two flex-grow options in Tailwind CSS, and all attributes are covered in class form. It is an alternative to...

3 minutes read.

Tailwind CSS Fill

The CSS Fill class accepts a lot of value, and all of the properties are covered in class form. It is a presentation attribute that controls how an SVG shape's...

1 minute read.

Tailwind CSS Position

The position class acknowledges more than one value in tailwind CSS. It is an option in contrast to the CSS Position property. This class is utilized for controlling how an...

5 minutes read.

Tailwind CSS Min-Height

In tailwind CSS, this class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Min-Height Property. It...

2 minutes read.