Text of v1.tailwindcss.com › docs › flex as Styx crawled it on Nov 18, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

Flex - Tailwind CSS

Flex Utilities for controlling how flex items both grow and shrink. Class reference Class Properties .flex-1 flex: 1 1 0%; .flex-auto flex: 1 1 auto; .flex-initial flex: 0 1 auto; .flex-none flex: none; Initial Use .flex-initial to allow a flex item to shrink but not grow, taking into account its initial size: Items don't grow when there's extra space Short Medium length Items shrink if possible when needed Short Medium length Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Qui ad labore ipsam, aut rem quo repellat esse tempore id, quidem < div class = " flex bg-gray-200 " > < div class = " flex-initial text-gray-700 text-center bg-gray-400 px-4 py-2 m-2 " > Short </ div > < div class = " flex-initial text-gray-700 text-center bg-gray-400 px-4 py-2 m-2 " > Medium length </ div > </ div > < div class = " flex bg-gray-200 " > < div class = " flex-initial text-gray-700 text-center bg-gray-400 px-4 py-2 m-2 " > Short </ div > < div class = " flex-initial text-gray-700 text-center bg-gray-400 px-4 py-2 m-2 " > Medium length </ div > < div class = " flex-initial text-gray-700 text-center bg-gray-400 px-4 py-2 m-2 " > Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Qui ad labore ipsam, aut rem quo repellat esse tempore id, quidem </ div > </ div > Flex 1 Use .flex-1 to allow a flex item to grow and shrink as needed, ignoring its initial size: Default behavior Short Medium length Significantly larger amount of content With .flex-1 Short Medium length Significantly larger amount of content < div class = " flex bg-gray-200 " > < div class = " flex-1 text-gray-700 text-center bg-gray-400 px-4 py-2 m-2 " > Short </ div > < div class = " flex-1 text-gray-700 text-center bg-gray-400 px-4 py-2 m-2 " > Medium length </ div > < div class = " flex-1 text-gray-700 text-center bg-gray-400 px-4 py-2 m-2 " > Significantly larger amount of content </ div > </ div > Auto Use .flex-auto to allow a flex item to grow and shrink, taking into account its initial size: Default behavior Short Medium length Significantly larger amount of content With .flex-auto Short Medium length Significantly larger amount of content < div class = " flex bg-gray-200 " > < div class = " flex-auto text-gray-700 text-center bg-gray-400 px-4 py-2 m-2 " > Short </ div > < div class = " flex-auto text-gray-700 text-center bg-gray-400 px-4 py-2 m-2 " > Medium length </ div > < div class = " flex-auto text-gray-700 text-center bg-gray-400 px-4 py-2 m-2 " > Significantly larger amount of content </ div > </ div > None Use .flex-none to prevent a flex item from growing or shrinking: Item that can grow or shrink if needed Item that cannot grow or shrink Item that can grow or shrink if needed < div class = " flex bg-gray-200 " > < div class = " flex-1 text-gray-700 text-center bg-gray-400 px-4 py-2 m-2 " > Item that can grow or shrink if needed </ div > < div class = " flex-none text-gray-800 text-center bg-gray-500 px-4 py-2 m-2 " > Item that cannot grow or shrink </ div > < div class = " flex-1 text-gray-700 text-center bg-gray-400 px-4 py-2 m-2 " > Item that can grow or shrink if needed </ div > </ div > Responsive To control how a flex item both grows and shrinks at a specific breakpoint, add a {screen}: prefix to any existing utility class.

For example, use md:flex-1 to apply the flex-1 utility at only medium screen sizes and above. For more information about Tailwind's responsive design features, check out the Responsive Design documentation. <div class="flex ..."> <!-- ... --> <div class=" flex-none sm:flex-1 md:flex-auto lg:flex-initial xl:flex-1 ..."> Responsive flex item </div> <!-- ... --> </div> Item that can grow or shrink if needed Responsive flex item Item that can grow or shrink if needed Customizing Flex Values By default Tailwind provides four flex utilities.

You change, add, or remove these by editing the theme.flex section of your Tailwind config. // tailwind.config.js module.exports = { theme: { flex: { '1': '1 1 0%', auto: '1 1 auto', - initial: '0 1 auto', + inherit: 'inherit', none: 'none', + '2': '2 2 0%', } } } Responsive and pseudo-class variants By default, only responsive variants are generated for flex utilities. You can control which variants are generated for the flex utilities by modifying the flex property in the variants section of your tailwind.config.js file.

For example, this config will also generate hover and focus variants: // tailwind.config.js module.exports = { variants : { // ... - flex : ['responsive'] , + flex : ['responsive', 'hover', 'focus'] , } } Disabling If you don't plan to use the flex utilities in your project, you can disable them entirely by setting the flex property to false in the corePlugins section of your config file: // tailwind.config.js module.exports = { corePlugins : { // ... + flex : false , } } ← Flex Wrap Flex Grow → On this page Class reference Initial Flex 1 Auto None Responsive Customizing Flex Values Responsive and pseudo-class variants Disabling Beautiful UI components by the creators of Tailwind CSS.

Learn more → Tailwind UI is now in early access! Now in early access! Beautiful UI components by the creators of Tailwind CSS. Beautiful UI components, crafted by the creators of Tailwind CSS. Learn more