Class reference

Flex, Grow, & Shrink - 图1

Initial Default

Use .flex-initial to allow a flex item to shrink but not grow, taking into account its initial size:

Flex, Grow, & Shrink - 图2

Flex 1

Use .flex-1 to allow a flex item to grow and shrink as needed, ignoring its initial size:

Flex, Grow, & Shrink - 图3

Auto

Use .flex-auto to allow a flex item to grow and shrink, taking into account its initial size:

Flex, Grow, & Shrink - 图4

None

Use .flex-none to prevent a flex item from growing or shrinking:

Flex, Grow, & Shrink - 图5

Grow

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

Flex, Grow, & Shrink - 图6

Don’t grow

Use .flex-no-grow to prevent a flex item from growing:

Flex, Grow, & Shrink - 图7

Shrink

Use .flex-shrink to allow a flex item to shrink if needed:

Flex, Grow, & Shrink - 图8

Don’t shrink

Use .flex-no-shrink to prevent a flex item from shrinking:

Flex, Grow, & Shrink - 图9

Responsive

To control how a flex item grows or shrinks at a specific breakpoint, add a {screen}: prefix to any existing utility class. For example, use md:flex-no-shrink to apply the flex-no-shrink utility at only medium screen sizes and above.

For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.

Flex, Grow, & Shrink - 图10

all

Flex, Grow, & Shrink - 图11

sm

Flex, Grow, & Shrink - 图12

md

Flex, Grow, & Shrink - 图13

lg

Flex, Grow, & Shrink - 图14

xl

Flex, Grow, & Shrink - 图15

Customizing

Responsive and State Variants

By default, only responsive variants are generated for flex, grow, and shrink utilities.

You can control which variants are generated for the flex, grow, and shrink utilities by modifying the flexbox property in the modules section of your Tailwind config file.

For example, this config will also generate hover and focus variants:

Flex, Grow, & Shrink - 图16

Note that modifying the flexbox property will affect which variants are generated for all Flexbox utilities, not just the flex, grow, and shrink utilities.

Disabling

If you don’t plan to use the flex, grow, and shrink utilities in your project, you can disable them entirely by setting the flexbox property to false in the modules section of your config file:

Flex, Grow, & Shrink - 图17

Note that modifying the flexbox property will affect which variants are generated for all Flexbox utilities, not just the flex, grow, and shrink utilities.