Flexbox & Grid

Flex Grow

Utilities for controlling how flex items grow.

Quick reference

Class
Properties
growflex-grow: 1;
grow-0flex-grow: 0;

Basic usage

Grow

Use grow to allow a flex item to grow to fill any available space:

Flex Grow - 图1

  1. <div class="flex ...">
  2. <div class="flex-none w-14 h-14 ...">
  3. 01
  4. </div>
  5. <div class="grow h-14 ...">
  6. 02
  7. </div>
  8. <div class="flex-none w-14 h-14 ...">
  9. 03
  10. </div>
  11. </div>

Don’t grow

Use grow-0 to prevent a flex item from growing:

Flex Grow - 图2

  1. <div class="flex ...">
  2. <div class="grow h-14 ...">
  3. 01
  4. </div>
  5. <div class="grow-0 h-14 ...">
  6. 02
  7. </div>
  8. <div class="grow h-14 ...">
  9. 03
  10. </div>
  11. </div>

Applying conditionally

Hover, focus, and other states

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:grow-0 to only apply the grow-0 utility on hover.

  1. <div class="grow hover:grow-0">
  2. <!-- ... -->
  3. </div>

For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

Breakpoints and media queries

You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:grow-0 to apply the grow-0 utility at only medium screen sizes and above.

  1. <div class="grow md:grow-0">
  2. <!-- ... -->
  3. </div>

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.


Using custom values

Customizing your theme

By default, Tailwind provides two grow utilities. You can customize these values by editing theme.flexGrow or theme.extend.flexGrow in your tailwind.config.js file.

tailwind.config.js

  1. module.exports = { theme: { extend: { flexGrow: { '2': 2 } } }}

Learn more about customizing the default theme in the theme customization documentation.

Arbitrary values

If you need to use a one-off flex-grow value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.

  1. <div class="grow-[2]">
  2. <!-- ... -->
  3. </div>

Learn more about arbitrary value support in the arbitrary values documentation.