Tailwind Flexbox Generator

Generate Tailwind CSS flexbox layouts visually. Set direction, wrap, justify, align, gap, and flex item sizing. Live preview with generated Tailwind code. Free browser tool.

How to use Tailwind Flexbox Generator

  1. 1

    Set flex direction (row, col, row-reverse, col-reverse).

  2. 2

    Choose justify-content for main axis alignment.

  3. 3

    Choose align-items for cross axis alignment.

  4. 4

    Set gap between items.

  5. 5

    Preview and copy the generated Tailwind flex classes.

Frequently Asked Questions

How do I center items with Tailwind Flexbox?

Use flex items-center justify-center on the container. For full-screen centering: flex items-center justify-center min-h-screen.

What does flex-1 do in Tailwind?

flex-1 means the element will grow and shrink as needed, taking up all available space. It is equivalent to flex: 1 1 0%.

How do I prevent a flex item from shrinking?

Use shrink-0 (flex-shrink: 0) on the item. Common use case: icons and logos next to text that should never compress.

Detailed Guide

Flexbox in Tailwind CSS

Flexbox is the go-to layout system for one-dimensional layouts — arranging items in a row or a column. Tailwind makes it intuitive with utility classes that mirror the underlying CSS properties but with more concise naming.


Enabling Flex and Direction

<div class="flex">          <!-- display: flex -->
<div class="inline-flex">   <!-- display: inline-flex -->
<div class="flex flex-col"> <!-- column direction -->
<div class="flex flex-row"> <!-- row direction (default) -->
<div class="flex flex-row-reverse"> <!-- reverse row -->
<div class="flex flex-col-reverse"> <!-- reverse column -->

Wrapping

<div class="flex flex-wrap">    <!-- wrap to next line -->
<div class="flex flex-nowrap">  <!-- no wrap (default) -->
<div class="flex flex-wrap-reverse"> <!-- wrap in reverse -->

Justify Content (Main Axis)

ClassCSS
justify-startjustify-content: flex-start
justify-centerjustify-content: center
justify-endjustify-content: flex-end
justify-betweenjustify-content: space-between
justify-aroundjustify-content: space-around
justify-evenlyjustify-content: space-evenly

Align Items (Cross Axis)

ClassCSS
items-startalign-items: flex-start
items-centeralign-items: center
items-endalign-items: flex-end
items-stretchalign-items: stretch (default)
items-baselinealign-items: baseline

Gap Between Items

<div class="flex gap-4">   <!-- gap: 1rem on all sides -->
<div class="flex gap-x-4"> <!-- column gap only -->
<div class="flex gap-y-2"> <!-- row gap only -->

Gap is the modern replacement for margin hacks between flex items.


Flex Item Sizing

<!-- Grow to fill available space -->
<div class="flex-1">    <!-- flex: 1 1 0% -->
<div class="flex-auto">  <!-- flex: 1 1 auto -->

<!-- Don't grow or shrink -->
<div class="flex-none">  <!-- flex: none -->

<!-- Control individually -->
<div class="grow">   <!-- flex-grow: 1 -->
<div class="shrink-0"> <!-- flex-shrink: 0 (prevent shrinking) -->

Common Flex Patterns

Centered content (horizontal + vertical):

<div class="flex items-center justify-center h-screen">

Space between label and value:

<div class="flex items-center justify-between">
  <span>Label</span>
  <span>Value</span>
</div>

Sticky footer:

Looking for a more detailed deep-dive and advanced tips?

Read Full Article on our Blog