flex-1: Tailwind CSS Flex class

The flex-1 class makes an element take up an equal share of the available space in a flex container.


Flex-1 (Flex Grow, Shrink, and Basis)

The flex-1 class makes an element take up an equal share of the available space in a flex container.

Example Code

html
<div class="flex p-10 bg-gray-100 space-x-5">
<div class="flex-1 bg-red-400 p-4 text-center text-white font-bold rounded">Flex Item 1</div>
<div class="flex-1 bg-blue-400 p-4 text-center text-white font-bold rounded">Flex Item 2</div>
</div>

Preview

Flex Item 1
Flex Item 2

How to Use

Add the flex-1 class directly to your HTML element:

html
<div class="flex-1">
<!-- Your content here -->
</div>

Responsive Usage

Use Tailwind's responsive prefixes to apply flex-1 at specific breakpoints:

html
<div class="sm:flex-1 md:flex-1 lg:flex-1">
Responsive element
</div>
  • sm:flex-1 — applies from 640px and up
  • md:flex-1 — applies from 768px and up
  • lg:flex-1 — applies from 1024px and up

Customization

You can extend or override this utility in your tailwind.config.js. See the Tailwind CSS documentation for details on customizing your theme.

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