Flex
Utilities for controlling how flex items both grow and shrink.
Default class reference
| Class | Properties |
|---|---|
| flex-1 | flex: 1 1 0%; |
| flex-auto | flex: 1 1 auto; |
| flex-initial | flex: 0 1 auto; |
| flex-none | flex: none; |
Initial
Use flex-initial to allow a flex item to shrink but not grow, taking into account its initial size:

1. <div class="flex">
2. <div class="flex-initial ...">
3. <!-- Won't grow, but will shrink if needed -->
4. </div>
5. <div class="flex-initial ...">
6. <!-- Won't grow, but will shrink if needed -->
7. </div>
8. <div class="flex-initial ...">
9. <!-- Won't grow, but will shrink if needed -->
10. </div>
11. </div>
Flex 1
Use flex-1 to allow a flex item to grow and shrink as needed, ignoring its initial size:

1. <div class="flex">
2. <div class="flex-1 ...">
3. <!-- Will grow and shrink as needed without taking initial size into account -->
4. </div>
5. <div class="flex-1 ...">
6. <!-- Will grow and shrink as needed without taking initial size into account -->
7. </div>
8. <div class="flex-1 ...">
9. <!-- Will grow and shrink as needed without taking initial size into account -->
10. </div>
11. </div>
Auto
Use flex-auto to allow a flex item to grow and shrink, taking into account its initial size:

1. <div class="flex ...">
2. <div class="flex-auto ...">
3. <!-- Will grow and shrink as needed taking initial size into account -->
4. </div>
5. <div class="flex-auto ...">
6. <!-- Will grow and shrink as needed taking initial size into account -->
7. </div>
8. <div class="flex-auto ...">
9. <!-- Will grow and shrink as needed taking initial size into account -->
10. </div>
11. </div>
None
Use flex-none to prevent a flex item from growing or shrinking:

1. <div class="flex ...">
2. <div class="flex-1 ...">
3. <!-- Will grow and shrink as needed -->
4. </div>
5. <div class="flex-none ...">
6. <!-- Will not grow or shrink -->
7. </div>
8. <div class="flex-1 ...">
9. <!-- Will grow and shrink as needed -->
10. </div>
11. </div>
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.
1. <div class="flex ...">
2. <!-- ... -->
3. <div class="flex-none md:flex-1 ...">
4. Responsive flex item
5. </div>
6. <!-- ... -->
7. </div>
For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.
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.
1. // tailwind.config.js
2. module.exports = {
3. theme: {
4. flex: {
5. '1': '1 1 0%',
6. auto: '1 1 auto',
7. - initial: '0 1 auto',
8. + inherit: 'inherit',
9. none: 'none',
10. + '2': '2 2 0%',
11. }
12. }
13. }
Variants
By default, only responsive variants are generated for flex utilities.
You can control which variants are generated for the flex utilities by modifying the flex property in the variants section of your tailwind.config.js file.
For example, this config will also generate hover and focus variants:
1. // tailwind.config.js
2. module.exports = {
3. variants: {
4. extend: {
5. // ...
6. + flex: ['hover', 'focus'],
7. }
8. }
9. }
Disabling
If you don’t plan to use the flex utilities in your project, you can disable them entirely by setting the flex property to false in the corePlugins section of your config file:
1. // tailwind.config.js
2. module.exports = {
3. corePlugins: {
4. // ...
5. + flex: false,
6. }
7. }
