Flex
@include('_partials.class-table', [ 'rows' => [ [ '.flex-initial', 'flex: 0 1 auto;', "Allow a flex item to shrink but not grow, taking into account its initial size.", ], [ '.flex-1', 'flex: 1 1 0%;', "Allow a flex item to grow and shrink as needed, ignoring its initial size.", ], [ '.flex-auto', 'flex: 1 1 auto;', "Allow a flex item to grow and shrink, taking into account its initial size.", ], [ '.flex-none', 'flex: none;', "Prevent a flex item from growing or shrinking.", ], ] ])
Initial
Use .flex-initial
to allow a flex item to shrink but not grow, taking into account its initial size:
@component('_partials.code-sample')
Items don't grow when there's extra space
Items shrink if possible when needed
@slot('code')
Flex 1
Use .flex-1
to allow a flex item to grow and shrink as needed, ignoring its initial size:
@component('_partials.code-sample')
Default behavior
With .flex-1
@slot('code')
Auto
Use .flex-auto
to allow a flex item to grow and shrink, taking into account its initial size:
@component('_partials.code-sample')
Default behavior
With .flex-auto
@slot('code')
None
Use .flex-none
to prevent a flex item from growing or shrinking:
@component('_partials.code-sample')
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.
@component('_partials.responsive-code-sample') @slot('none')
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.
@component('_partials.customized-config', ['key' => 'theme.flex']) '1': '1 1 0%', auto: '1 1 auto',
- initial: '0 1 auto',
- inherit: 'inherit', none: 'none',
- '2': '2 2 0%', @endcomponent
@include('_partials.variants-and-disabling', [ 'utility' => [ 'name' => 'flex', 'property' => 'flex', ], 'variants' => [ 'responsive', ], ])