BlogPlaygroundOne

Flex

Control the layout of flex containers with alignment, justification and more with responsive flexbox utilities.

Edit this page
Report a Bug
Copy Page as Markdown
ClassProperties
d-flexdisplay: flex;
d-inline-flexdisplay: inline-flex;
d-sm-flexdisplay: flex;
d-sm-inline-flexdisplay: inline-flex;
d-md-flexdisplay: flex;
d-md-inline-flexdisplay: inline-flex;
d-lg-flexdisplay: flex;
d-lg-inline-flexdisplay: inline-flex;
d-xl-flexdisplay: flex;
d-xl-inline-flexdisplay: inline-flex;
flex-fillflex: 1 1 auto;
flex-sm-fillflex: 1 1 auto;
flex-md-fillflex: 1 1 auto;
flex-lg-fillflex: 1 1 auto;
flex-xl-fillflex: 1 1 auto;
flex-1-1flex: 1 1 auto;
flex-sm-1-1flex: 1 1 auto;
flex-md-1-1flex: 1 1 auto;
flex-lg-1-1flex: 1 1 auto;
flex-xl-1-1flex: 1 1 auto;
flex-1-0flex: 1 0 auto;
flex-sm-1-0flex: 1 0 auto;
flex-md-1-0flex: 1 0 auto;
flex-lg-1-0flex: 1 0 auto;
flex-xl-1-0flex: 1 0 auto;
flex-0-1flex: 0 1 auto;
flex-sm-0-1flex: 0 1 auto;
flex-md-0-1flex: 0 1 auto;
flex-lg-0-1flex: 0 1 auto;
flex-xl-0-1flex: 0 1 auto;
flex-0-0flex: 0 0 auto;
flex-sm-0-0flex: 0 0 auto;
flex-md-0-0flex: 0 0 auto;
flex-lg-0-0flex: 0 0 auto;
flex-xl-0-0flex: 0 0 auto;
flex-1-1-0flex: 1 1 0%;
flex-sm-1-1-0flex: 1 1 0%;
flex-md-1-1-0flex: 1 1 0%;
flex-lg-1-1-0flex: 1 1 0%;
flex-xl-1-1-0flex: 1 1 0%;
flex-1-1-100flex: 1 1 100%;
flex-sm-1-1-100flex: 1 1 100%;
flex-md-1-1-100flex: 1 1 100%;
flex-lg-1-1-100flex: 1 1 100%;
flex-xl-1-1-100flex: 1 1 100%;
flex-1-0-0flex: 1 0 0%;
flex-sm-1-0-0flex: 1 0 0%;
flex-md-1-0-0flex: 1 0 0%;
flex-lg-1-0-0flex: 1 0 0%;
flex-xl-1-0-0flex: 1 0 0%;
flex-1-0-100flex: 1 0 100%;
flex-sm-1-0-100flex: 1 0 100%;
flex-md-1-0-100flex: 1 0 100%;
flex-lg-1-0-100flex: 1 0 100%;
flex-xl-1-0-100flex: 1 0 100%;
flex-0-1-0flex: 0 1 0%;
flex-sm-0-1-0flex: 0 1 0%;
flex-md-0-1-0flex: 0 1 0%;
flex-lg-0-1-0flex: 0 1 0%;
flex-xl-0-1-0flex: 0 1 0%;
flex-0-1-100flex: 0 1 100%;
flex-sm-0-1-100flex: 0 1 100%;
flex-md-0-1-100flex: 0 1 100%;
flex-lg-0-1-100flex: 0 1 100%;
flex-xl-0-1-100flex: 0 1 100%;
flex-0-0-0flex: 0 0 0%
flex-sm-0-0-0flex: 0 0 0%
flex-md-0-0-0flex: 0 0 0%
flex-lg-0-0-0flex: 0 0 0%
flex-xl-0-0-0flex: 0 0 0%
flex-0-0-100flex: 0 0 100%;
flex-sm-0-0-100flex: 0 0 100%;
flex-md-0-0-100flex: 0 0 100%;
flex-lg-0-0-100flex: 0 0 100%;
flex-xl-0-0-100flex: 0 0 100%;
ga-0gap: 0;
ga-1gap: 4px;
ga-2gap: 8px;
ga-3gap: 12px;
ga-4gap: 16px;
ga-5gap: 20px;
ga-6gap: 24px;
ga-7gap: 28px;
ga-8gap: 32px;
ga-9gap: 36px;
ga-10gap: 40px;
ga-11gap: 44px;
ga-12gap: 48px;
ga-13gap: 52px;
ga-14gap: 56px;
ga-15gap: 60px;
ga-16gap: 64px;
ga-sm-0gap: 0;
ga-sm-1gap: 4px;
ga-sm-2gap: 8px;
ga-sm-3gap: 12px;
ga-sm-4gap: 16px;
ga-sm-5gap: 20px;
ga-sm-6gap: 24px;
ga-sm-7gap: 28px;
ga-sm-8gap: 32px;
ga-sm-9gap: 36px;
ga-sm-10gap: 40px;
ga-sm-11gap: 44px;
ga-sm-12gap: 48px;
ga-sm-13gap: 52px;
ga-sm-14gap: 56px;
ga-sm-15gap: 60px;
ga-sm-16gap: 64px;
ga-md-0gap: 0;
ga-md-1gap: 4px;
ga-md-2gap: 8px;
ga-md-3gap: 12px;
ga-md-4gap: 16px;
ga-md-5gap: 20px;
ga-md-6gap: 24px;
ga-md-7gap: 28px;
ga-md-8gap: 32px;
ga-md-9gap: 36px;
ga-md-10gap: 40px;
ga-md-11gap: 44px;
ga-md-12gap: 48px;
ga-md-13gap: 52px;
ga-md-14gap: 56px;
ga-md-15gap: 60px;
ga-md-16gap: 64px;
ga-lg-0gap: 0;
ga-lg-1gap: 4px;
ga-lg-2gap: 8px;
ga-lg-3gap: 12px;
ga-lg-4gap: 16px;
ga-lg-5gap: 20px;
ga-lg-6gap: 24px;
ga-lg-7gap: 28px;
ga-lg-8gap: 32px;
ga-lg-9gap: 36px;
ga-lg-10gap: 40px;
ga-lg-11gap: 44px;
ga-lg-12gap: 48px;
ga-lg-13gap: 52px;
ga-lg-14gap: 56px;
ga-lg-15gap: 60px;
ga-lg-16gap: 64px;
ga-xl-0gap: 0;
ga-xl-1gap: 4px;
ga-xl-2gap: 8px;
ga-xl-3gap: 12px;
ga-xl-4gap: 16px;
ga-xl-5gap: 20px;
ga-xl-6gap: 24px;
ga-xl-7gap: 28px;
ga-xl-8gap: 32px;
ga-xl-9gap: 36px;
ga-xl-10gap: 40px;
ga-xl-11gap: 44px;
ga-xl-12gap: 48px;
ga-xl-13gap: 52px;
ga-xl-14gap: 56px;
ga-xl-15gap: 60px;
ga-xl-16gap: 64px;
flex-rowflex-direction: row;
flex-row-reverseflex-direction: row-reverse;
flex-columnflex-direction: column;
flex-column-reverseflex-direction: column-reverse;
flex-sm-rowflex-direction: row;
flex-sm-row-reverseflex-direction: row-reverse;
flex-sm-columnflex-direction: column;
flex-sm-column-reverseflex-direction: column-reverse;
flex-md-rowflex-direction: row;
flex-md-row-reverseflex-direction: row-reverse;
flex-md-columnflex-direction: column;
flex-md-column-reverseflex-direction: column-reverse;
flex-lg-rowflex-direction: row;
flex-lg-row-reverseflex-direction: row-reverse;
flex-lg-columnflex-direction: column;
flex-lg-column-reverseflex-direction: column-reverse;
flex-xl-rowflex-direction: row;
flex-xl-row-reverseflex-direction: row-reverse;
flex-xl-columnflex-direction: column;
flex-xl-column-reverseflex-direction: column-reverse;
justify-startjustify-content: flex-start;
justify-endjustify-content: flex-end;
justify-centerjustify-content: center;
justify-space-betweenjustify-content: space-between;
justify-space-aroundjustify-content: space-around;
justify-space-evenlyjustify-content: space-evenly;
justify-sm-startjustify-content: flex-start;
justify-sm-endjustify-content: flex-end;
justify-sm-centerjustify-content: center;
justify-sm-space-betweenjustify-content: space-between;
justify-sm-space-aroundjustify-content: space-around;
justify-sm-space-evenlyjustify-content: space-evenly;
justify-md-startjustify-content: flex-start;
justify-md-endjustify-content: flex-end;
justify-md-centerjustify-content: center;
justify-md-space-betweenjustify-content: space-between;
justify-md-space-aroundjustify-content: space-around;
justify-md-space-evenlyjustify-content: space-evenly;
justify-lg-startjustify-content: flex-start;
justify-lg-endjustify-content: flex-end;
justify-lg-centerjustify-content: center;
justify-lg-space-betweenjustify-content: space-between;
justify-lg-space-aroundjustify-content: space-around;
justify-lg-space-evenlyjustify-content: space-evenly;
justify-xl-startjustify-content: flex-start;
justify-xl-endjustify-content: flex-end;
justify-xl-centerjustify-content: center;
justify-xl-space-betweenjustify-content: space-between;
justify-xl-space-aroundjustify-content: space-around;
justify-xl-space-evenlyjustify-content: space-evenly;
align-startalign-items: flex-start;
align-endalign-items: flex-end;
align-centeralign-items: center;
align-baselinealign-items: baseline;
align-stretchalign-items: stretch;
align-sm-startalign-items: flex-start;
align-sm-endalign-items: flex-end;
align-sm-centeralign-items: center;
align-sm-baselinealign-items: baseline;
align-sm-stretchalign-items: stretch;
align-md-startalign-items: flex-start;
align-md-endalign-items: flex-end;
align-md-centeralign-items: center;
align-md-baselinealign-items: baseline;
align-md-stretchalign-items: stretch;
align-lg-startalign-items: flex-start;
align-lg-endalign-items: flex-end;
align-lg-centeralign-items: center;
align-lg-baselinealign-items: baseline;
align-lg-stretchalign-items: stretch;
align-xl-startalign-items: flex-start;
align-xl-endalign-items: flex-end;
align-xl-centeralign-items: center;
align-xl-baselinealign-items: baseline;
align-xl-stretchalign-items: stretch;
align-self-startalign-self: flex-start;
align-self-endalign-self: flex-end;
align-self-centeralign-self: center;
align-self-baselinealign-self: baseline;
align-self-autoalign-self: auto;
align-self-stretchalign-self: stretch;
align-self-sm-startalign-self: flex-start;
align-self-sm-endalign-self: flex-end;
align-self-sm-centeralign-self: center;
align-self-sm-baselinealign-self: baseline;
align-self-sm-autoalign-self: auto;
align-self-sm-stretchalign-self: stretch;
align-self-md-startalign-self: flex-start;
align-self-md-endalign-self: flex-end;
align-self-md-centeralign-self: center;
align-self-md-baselinealign-self: baseline;
align-self-md-autoalign-self: auto;
align-self-md-stretchalign-self: stretch;
align-self-lg-startalign-self: flex-start;
align-self-lg-endalign-self: flex-end;
align-self-lg-centeralign-self: center;
align-self-lg-baselinealign-self: baseline;
align-self-lg-autoalign-self: auto;
align-self-lg-stretchalign-self: stretch;
align-self-xl-startalign-self: flex-start;
align-self-xl-endalign-self: flex-end;
align-self-xl-centeralign-self: center;
align-self-xl-baselinealign-self: baseline;
align-self-xl-autoalign-self: auto;
align-self-xl-stretchalign-self: stretch;
flex-sm-nowrapflex-wrap: nowrap;
flex-sm-wrapflex-wrap: wrap;
flex-sm-wrap-reverseflex-wrap: wrap-reverse;
flex-md-nowrapflex-wrap: nowrap;
flex-md-wrapflex-wrap: wrap;
flex-md-wrap-reverseflex-wrap: wrap-reverse;
flex-lg-nowrapflex-wrap: nowrap;
flex-lg-wrapflex-wrap: wrap;
flex-lg-wrap-reverseflex-wrap: wrap-reverse;
flex-xl-nowrapflex-wrap: nowrap;
flex-xl-wrapflex-wrap: wrap;
flex-xl-wrap-reverseflex-wrap: wrap-reverse;
order-firstorder: -1;
order-0order: 0;
order-1order: 1;
order-2order: 2;
order-3order: 3;
order-4order: 4;
order-5order: 5;
order-6order: 6;
order-7order: 7;
order-8order: 8;
order-9order: 9;
order-10order: 10;
order-11order: 11;
order-12order: 12;
order-lastorder: 13;
order-sm-firstorder: -1;
order-sm-0order: 0;
order-sm-1order: 1;
order-sm-2order: 2;
order-sm-3order: 3;
order-sm-4order: 4;
order-sm-5order: 5;
order-sm-6order: 6;
order-sm-7order: 7;
order-sm-8order: 8;
order-sm-9order: 9;
order-sm-10order: 10;
order-sm-11order: 11;
order-sm-12order: 12;
order-sm-lastorder: 13;
order-md-firstorder: -1;
order-md-0order: 0;
order-md-1order: 1;
order-md-2order: 2;
order-md-3order: 3;
order-md-4order: 4;
order-md-5order: 5;
order-md-6order: 6;
order-md-7order: 7;
order-md-8order: 8;
order-md-9order: 9;
order-md-10order: 10;
order-md-11order: 11;
order-md-12order: 12;
order-md-lastorder: 13;
order-lg-firstorder: -1;
order-lg-0order: 0;
order-lg-1order: 1;
order-lg-2order: 2;
order-lg-3order: 3;
order-lg-4order: 4;
order-lg-5order: 5;
order-lg-6order: 6;
order-lg-7order: 7;
order-lg-8order: 8;
order-lg-9order: 9;
order-lg-10order: 10;
order-lg-11order: 11;
order-lg-12order: 12;
order-lg-lastorder: 13;
order-xl-firstorder: -1;
order-xl-0order: 0;
order-xl-1order: 1;
order-xl-2order: 2;
order-xl-3order: 3;
order-xl-4order: 4;
order-xl-5order: 5;
order-xl-6order: 6;
order-xl-7order: 7;
order-xl-8order: 8;
order-xl-9order: 9;
order-xl-10order: 10;
order-xl-11order: 11;
order-xl-12order: 12;
order-xl-lastorder: 13;
align-content-startalign-content: flex-start;
align-content-endalign-content: flex-end;
align-content-centeralign-content: center;
align-content-space-betweenalign-content: space-between;
align-content-space-aroundalign-content: space-around;
align-content-space-evenlyalign-content: space-evenly;
align-content-stretchalign-content: stretch;
align-content-sm-startalign-content: flex-start;
align-content-sm-endalign-content: flex-end;
align-content-sm-centeralign-content: center;
align-content-sm-space-betweenalign-content: space-between;
align-content-sm-space-aroundalign-content: space-around;
align-content-sm-space-evenlyalign-content: space-evenly;
align-content-sm-stretchalign-content: stretch;
align-content-md-startalign-content: flex-start;
align-content-md-endalign-content: flex-end;
align-content-md-centeralign-content: center;
align-content-md-space-betweenalign-content: space-between;
align-content-md-space-aroundalign-content: space-around;
align-content-md-space-evenlyalign-content: space-evenly;
align-content-md-stretchalign-content: stretch;
align-content-lg-startalign-content: flex-start;
align-content-lg-endalign-content: flex-end;
align-content-lg-centeralign-content: center;
align-content-lg-space-betweenalign-content: space-between;
align-content-lg-space-aroundalign-content: space-around;
align-content-lg-space-evenlyalign-content: space-evenly;
align-content-lg-stretchalign-content: stretch;
align-content-xl-startalign-content: flex-start;
align-content-xl-endalign-content: flex-end;
align-content-xl-centeralign-content: center;
align-content-xl-space-betweenalign-content: space-between;
align-content-xl-space-aroundalign-content: space-around;
align-content-xl-space-evenlyalign-content: space-evenly;
align-content-xl-stretchalign-content: stretch;
flex-nowrapflex-wrap: nowrap;
flex-wrapflex-wrap: wrap;
flex-wrap-reverseflex-wrap: wrap-reverse;
flex-grow-0flex-grow: 0;
flex-grow-1flex-grow: 1;
flex-shrink-0flex-shrink: 0;
flex-shrink-1flex-shrink: 1;
flex-sm-grow-0flex-grow: 0;
flex-md-grow-0flex-grow: 0;
flex-lg-grow-0flex-grow: 0;
flex-xl-grow-0flex-grow: 0;
flex-sm-grow-1flex-grow: 1;
flex-md-grow-1flex-grow: 1;
flex-lg-grow-1flex-grow: 1;
flex-xl-grow-1flex-grow: 1;
flex-sm-shrink-0flex-shrink: 0;
flex-md-shrink-0flex-shrink: 0;
flex-lg-shrink-0flex-shrink: 0;
flex-xl-shrink-0flex-shrink: 0;
flex-sm-shrink-1flex-shrink: 1;
flex-md-shrink-1flex-shrink: 1;
flex-lg-shrink-1flex-shrink: 1;
flex-xl-shrink-1flex-shrink: 1;

Usage

Using display utilities you can turn any element into a flexbox container transforming direct children elements into flex items. Using additional flex property utilities, you can customize their interaction even further.

I'm a single element in a flexbox container!
I'm a single element in an inline flexbox container!

You can also customize flex utilities to apply based upon various breakpoints.

Caveats

Flex shorthand

The flex utility classes can be used to modify the flex css property. This makes it easy to position flex items within a flex container.

I'm an element in an inline flexbox container!
I'm a single element in an inline flexbox container!
I'm a single element in an inline flexbox container!

Flex direction

By default, d-flex applies flex-direction: row and can generally be omitted. However, there may be situations where you need to explicitly define it.

Flex item 1
Flex item 2
Flex item 3
Flex item 1
Flex item 2
Flex item 3

The flex-column and flex-column-reverse utility classes can be used to change the orientation of the flexbox container.

Flex item 1
Flex item 2
Flex item 3
Flex item 1
Flex item 2
Flex item 3

Flex justify

The justify-content flex setting can be changed using the flex justify classes. This by default will modify the flexbox items on the x-axis but is reversed when using flex-direction: column, modifying the y-axis. Choose from start (browser default), end, center, space-between, space-around, or space-evenly.

justify-start
justify-start
justify-start
justify-end
justify-end
justify-end
justify-center
justify-center
justify-center
justify-space-between
justify-space-between
justify-space-between
justify-space-around
justify-space-around
justify-space-around
justify-space-evenly
justify-space-evenly
justify-space-evenly

Flex align

The align-items flex setting can be changed using the flex align classes. This by default will modify the flexbox items on the y-axis but is reversed when using flex-direction: column, modifying the x-axis. Choose from start, end, center, baseline, or stretch (browser default).

align-start
align-start
align-start
align-end
align-end
align-end
align-center
align-center
align-center
align-baseline
align-baseline
align-baseline
align-stretch
align-stretch
align-stretch

Flex align self

The align-self flex setting can be changed using the flex align-self classes. This by default will modify individual flexbox items across the y-axis but is reversed when using flex-direction: column, modifying the x-axis. Choose from start, end, center, baseline, stretch, or auto (browser default, applies align-items property from flex container).

Flex item
align-self-start
Flex item
Flex item
align-self-end
Flex item
Flex item
align-self-center
Flex item
Flex item
align-self-baseline
Flex item
Flex item
align-self-auto
Flex item
Flex item
align-self-stretch
Flex item

Auto margins

Using the margin helper classes in a flexbox container, you can control the positioning of flex items on the x-axis or y-axis when using flex-row or flex-column respectively.

Flex item
Flex item
Flex item
Flex item
Flex item
Flex item
Flex item
Flex item
Flex item

Using align-items

Mixing flex-direction: column and align-items, you can utilize .mt-auto and .mb-auto helper classes to adjust flex item positioning.

Flex item
Flex item
Flex item
Flex item
Flex item
Flex item

Flex wrap

By default .d-flex does not provide any wrapping (behaves similarly to flex-wrap: nowrap). This can be modified by applying flex-wrap helper classes in the format flex-{condition} where condition can be nowrap, wrap, or wrap-reverse.

Flex item
Flex item
Flex item
Flex item
Flex item
Flex item 1
Flex item 2
Flex item 3
Flex item 4
Flex item 5
Flex item 6
Flex item 7
Flex item 8
Flex item 9
Flex item 10
Flex item 11
Flex item 12
Flex item 13
Flex item 14
Flex item 15
Flex item 16
Flex item 17
Flex item 18
Flex item 19
Flex item 20
Flex item 1
Flex item 2
Flex item 3
Flex item 4
Flex item 5
Flex item 6
Flex item 7
Flex item 8
Flex item 9
Flex item 10
Flex item 11
Flex item 12
Flex item 13
Flex item 14
Flex item 15
Flex item 16
Flex item 17
Flex item 18
Flex item 19
Flex item 20

These helper classes can also be applied in the format flex-{breakpoint}-{condition} to create more responsive variations based on breakpoints. The following combinations are available:

Flex order

You can change the visual order of flex items with the order utilities.

First flex item
Second flex item
Third flex item

Flex align content

The align-content flex setting can be changed using the flex align-content classes. This by default will modify the wrapped flexbox content across the y-axis but is reversed when using flex-direction: column, modifying the x-axis. Choose from start, end, center, space-between, space-around, space-evenly or stretch (browser default).

align-content-start
Flex item
Flex item
Flex item
Flex item
Flex item
align-content-center
Flex item
Flex item
Flex item
Flex item
Flex item
align-content-end
Flex item
Flex item
Flex item
Flex item
Flex item
align-content-space-between
Flex item
Flex item
Flex item
Flex item
Flex item
align-content-space-around
Flex item
Flex item
Flex item
Flex item
Flex item

Flex grow and shrink

Vuetify has helper classes for applying grow and shrink manually. These can be applied by adding the helper class in the format flex-{condition}-{value}, where condition can be either grow or shrink and value can be either 0 or 1. The condition grow will permit an element to grow to fill available space, whereas shrink will permit an element to shrink down to only the space needs for its contents. However, this will only happen if the element must shrink to fit their container such as a container resize or being effected by a flex-grow-1. The value 0 will prevent the condition from occurring whereas 1 will permit the condition. The following classes are available:

I'm 2 column wide
I'm 1 column wide and I grow to take all the space
I'm 5 column wide and I shrink if there's not enough space

These helper classes can also be applied in the format flex-{breakpoint}-{condition}-{state} to create more responsive variations based on breakpoints. The following combinations are available:

Ready for more?

Continue your learning with related content selected by the Team or move between pages by using the navigation links below.