×

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 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 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 Justify Self

The class form goes over the various properties. It's a replacement for the CSS justify-self attribute. This class is used to describe the alignment of content’s position in a CSS...

4 minutes read.

Tailwind CSS Stroke

This class accepts a lot of value, and all of the properties are covered in class form. It's the stroke class that goes on top of the SVG element. Stroke...

2 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 Place Items

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

4 minutes read.

Tailwind CSS Grid Row Start / End

In tailwind CSS, this class takes several values. All of the attributes are covered in the form of a class. In CSS, it's an alternative to the grid-row attribute. It's...

4 minutes read.

Tailwind CSS Display

It acknowledges more than one worth in tailwind CSS. Every one of the properties is shrouded as in class structure. It is an option in contrast to the CSS display...

5 minutes read.

Tailwind CSS Max-Height

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 Max-Height attribute. It is used to...

3 minutes read.

Tailwind CSS Top / Right / Bottom / Left

In tailwind CSS, these classes take a variety of values and cover all of the characteristics in the class form. These are the CSS Top/Right/Bottom/Left properties' replacements. These classes are...

4 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 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 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 Order

One of the best features of Tailwind CSS is the Order class, which allows us to order flex and grid objects according to our needs. There are several different order...

2 minutes read.

Tailwind CSS Container

In Tailwind CSS, a compartment is utilized to fix the maximum width (max-width) of a component to match the min-width of the breakpoint. It comes exceptionally convenient when content must...

2 minutes read.

Tailwind CSS Space Between

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 Space Between property....

4 minutes read.

Tailwind CSS Grid Auto Columns

The Grid Auto Columns class accepts multiple values, and all of the properties are covered in class form. It's a replacement for the CSS grid-auto-columns property. The size of the...

5 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 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 Width

The tailwind CSS width class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Width Property. This...

3 minutes read.