2017-10-23 16:27:11 -04:00
---
extends: _layouts.markdown
2017-10-27 08:05:44 -04:00
title: "Wrapping - Flexbox"
category: "Flexbox"
2017-10-23 16:27:11 -04:00
---
# Flex Wrapping
2017-10-29 19:29:54 -04:00
< div class = "text-xl text-slate-light mb-4" >
2017-10-27 14:17:40 -04:00
Utilities for controlling how flex items wrap.
< / div >
2017-10-29 19:29:54 -04:00
@include ('_partials.feature-badges', [
'responsive' => true,
'customizable' => false,
'hover' => false,
'focus' => false
])
< div class = "border-t border-grey-lighter" >
< table class = "w-full text-left" style = "border-collapse: collapse;" >
< colgroup >
< col class = "w-1/5" >
< col class = "w-2/5" >
< col class = "w-2/5" >
< / colgroup >
< thead >
< tr >
< th class = "text-sm font-semibold text-grey-darker p-2 bg-grey-lightest" > Class< / th >
< th class = "text-sm font-semibold text-grey-darker p-2 bg-grey-lightest" > Properties< / th >
< th class = "text-sm font-semibold text-grey-darker p-2 bg-grey-lightest" > Description< / th >
< / tr >
< / thead >
< tbody class = "align-baseline" >
< tr >
< td class = "p-2 border-t border-smoke-light font-mono text-xs text-purple-dark" > .flex-no-wrap< / td >
< td class = "p-2 border-t border-smoke-light font-mono text-xs text-blue-dark" > flex-wrap: nowrap;< / td >
< td class = "p-2 border-t border-smoke-light text-sm text-grey-darker" > Don't allow flex items to wrap.< / td >
< / tr >
< tr >
< td class = "p-2 border-t border-smoke-light font-mono text-xs text-purple-dark" > .flex-wrap< / td >
< td class = "p-2 border-t border-smoke-light font-mono text-xs text-blue-dark" > flex-wrap: wrap;< / td >
< td class = "p-2 border-t border-smoke-light text-sm text-grey-darker" > Allow flex items to wrap in the normal direction.< / td >
< / tr >
< tr >
< td class = "p-2 border-t border-smoke-light font-mono text-xs text-purple-dark" > .flex-wrap-reverse< / td >
< td class = "p-2 border-t border-smoke-light font-mono text-xs text-blue-dark" > flex-wrap: wrap-reverse;< / td >
< td class = "p-2 border-t border-smoke-light text-sm text-grey-darker" > Allow flex items to wrap in the reverse direction.< / td >
< / tr >
< / tbody >
< / table >
2017-10-23 16:27:11 -04:00
< / div >
2017-10-27 14:17:40 -04:00
### Don't wrap <span class="ml-2 font-semibold text-slate-light text-sm uppercase tracking-wide">Default</span>
2017-10-23 16:27:11 -04:00
2017-10-24 09:43:41 -04:00
Use `.flex-no-wrap` to prevent flex items from wrapping, causing inflexible items to overflow the container if necessary:
2017-10-23 16:27:11 -04:00
@component ('_partials.code-sample')
2017-10-24 07:44:34 -04:00
< div class = "flex flex-no-wrap bg-smoke-light" >
2017-10-24 09:43:41 -04:00
< div class = "w-2/5 flex-none p-2" >
2017-10-23 16:27:11 -04:00
< div class = "text-slate text-center bg-smoke p-2" > 1< / div >
< / div >
2017-10-24 09:43:41 -04:00
< div class = "w-2/5 flex-none p-2" >
2017-10-23 16:27:11 -04:00
< div class = "text-slate text-center bg-smoke p-2" > 2< / div >
< / div >
2017-10-24 09:43:41 -04:00
< div class = "w-2/5 flex-none p-2" >
2017-10-23 16:27:11 -04:00
< div class = "text-slate text-center bg-smoke p-2" > 3< / div >
< / div >
< / div >
@endcomponent
2017-10-27 14:17:40 -04:00
### Wrap normally
2017-10-23 16:27:11 -04:00
Use `.flex-wrap` to allow flex items to wrap:
@component ('_partials.code-sample')
< div class = "flex flex-wrap bg-smoke-light" >
< div class = "w-2/5 p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 1< / div >
< / div >
< div class = "w-2/5 p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 2< / div >
< / div >
< div class = "w-2/5 p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 3< / div >
< / div >
< / div >
@endcomponent
2017-10-27 14:17:40 -04:00
### Wrap reversed
2017-10-23 16:27:11 -04:00
Use `.flex-wrap-reverse` to wrap flex items in the reverse direction:
@component ('_partials.code-sample')
< div class = "flex flex-wrap-reverse bg-smoke-light" >
< div class = "w-2/5 p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 1< / div >
< / div >
< div class = "w-2/5 p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 2< / div >
< / div >
< div class = "w-2/5 p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 3< / div >
< / div >
< / div >
@endcomponent
2017-10-27 14:17:40 -04:00
## Responsive
To control how flex items wrap at a specific breakpoint, add a `{breakpoint}:` prefix to any existing utility class. For example, use `md:flex-wrap-reverse` to apply the `flex-wrap-reverse` 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')
< div class = "flex flex-no-wrap bg-smoke-light" >
< div class = "w-2/5 flex-none p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 1< / div >
< / div >
< div class = "w-2/5 flex-none p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 2< / div >
< / div >
< div class = "w-2/5 flex-none p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 3< / div >
< / div >
< / div >
@endslot
@slot ('sm')
< div class = "flex flex-wrap bg-smoke-light" >
< div class = "w-2/5 flex-none p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 1< / div >
< / div >
< div class = "w-2/5 flex-none p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 2< / div >
< / div >
< div class = "w-2/5 flex-none p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 3< / div >
< / div >
< / div >
@endslot
@slot ('md')
< div class = "flex flex-wrap-reverse bg-smoke-light" >
< div class = "w-2/5 flex-none p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 1< / div >
< / div >
< div class = "w-2/5 flex-none p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 2< / div >
< / div >
< div class = "w-2/5 flex-none p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 3< / div >
< / div >
< / div >
@endslot
@slot ('lg')
< div class = "flex flex-no-wrap bg-smoke-light" >
< div class = "w-2/5 flex-none p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 1< / div >
< / div >
< div class = "w-2/5 flex-none p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 2< / div >
< / div >
< div class = "w-2/5 flex-none p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 3< / div >
< / div >
< / div >
@endslot
@slot ('xl')
< div class = "flex flex-wrap bg-smoke-light" >
< div class = "w-2/5 flex-none p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 1< / div >
< / div >
< div class = "w-2/5 flex-none p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 2< / div >
< / div >
< div class = "w-2/5 flex-none p-2" >
< div class = "text-slate text-center bg-smoke p-2" > 3< / div >
< / div >
< / div >
@endslot
@slot ('code')
< div class = "none:flex-no-wrap sm:flex-wrap md:flex-wrap-reverse lg:flex-no-wrap xl:flex-wrap ..." >
<!-- ... -->
< / div >
@endslot
@endcomponent