11 KiB
| extends | title | description | features | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| _layouts.documentation | Flex, Grow, & Shrink | Utilities for controlling how flex items grow and shrink. |
|
@include('_partials.class-table', [ 'rows' => [ [ '.flex-initial', 'flex: initial;', "Allow a flex item to shrink but not grow, taking into account its initial size.", ], [ '.flex-1', 'flex: 1;', "Allow a flex item to grow and shrink as needed, ignoring its initial size.", ], [ '.flex-auto', 'flex: 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.", ], [ '.flex-grow', 'flex-grow: 1;', "Allow a flex item to grow to fill any available space.", ], [ '.flex-shrink', 'flex-shrink: 1;', "Allow a flex item to shrink if needed.", ], [ '.flex-no-grow', 'flex-grow: 0;', "Prevent a flex item from growing.", ], [ '.flex-no-shrink', 'flex-shrink: 0;', "Prevent a flex item from shrinking.", ], ] ])
Initial Default
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')
Grow
Use .flex-grow to allow a flex item to grow to fill any available space:
@component('_partials.code-sample')
Don't grow
Use .flex-no-grow to prevent a flex item from growing:
@component('_partials.code-sample')
Shrink
Use .flex-shrink to allow a flex item to shrink if needed:
@component('_partials.code-sample')
Don't shrink
Use .flex-no-shrink to prevent a flex item from shrinking:
@component('_partials.code-sample')
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.
@component('_partials.responsive-code-sample') @slot('none')