Skip to content

Flex

Display Flex

Use these utility classes to make elements become flex containers.

ClassValueCopy

  1. .d-flex
    display: flex
  2. .d-inline-flex
    display: inline-flex

Breakpoint infixes

Add the viewport sizing infixes (sm, md, lg, xl, xxl) to apply at breakpoints.

Note: these infixes apply to all Flex utilities, for example align-items-xl-end.

XSSmallMediumLargeXLXXLCopy
.d-flexFlexesFlexesFlexesFlexesFlexesFlexes
.d-sm-flexDoesn’t FlexFlexesFlexesFlexesFlexesFlexes
.d-md-flexDoesn’t FlexDoesn’t FlexFlexesFlexesFlexesFlexes
.d-lg-flexDoesn’t FlexDoesn’t FlexDoesn’t FlexFlexesFlexesFlexes
.d-xl-flexDoesn’t FlexDoesn’t FlexDoesn’t FlexDoesn’t FlexFlexesFlexes
.d-xxl-flexDoesn’t FlexDoesn’t FlexDoesn’t FlexDoesn’t FlexDoesn’t FlexFlexes

Align-items

ClassValueCopy

  1. .align-items-stretch
    align-items: stretch
  2. .align-items-start
    align-items: start
  3. .align-items-end
    align-items: end
  4. .align-items-center
    align-items: center
  5. .align-items-baseline
    align-items: baseline

Visual examples

.align-items-stretch

Item 1
Item 2
Item 3
Item 4

.align-items-start

Item 1
Item 2
Item 3
Item 4

.align-items-end

Item 1
Item 2
Item 3
Item 4

.align-items-center

Item 1
Item 2
Item 3
Item 4

.align-items-baseline

Item 1
Item 2
Item 3
Item 4

Align-self

Apply on flex items (as opposed to .align-items which is applied to flex containers).

ClassValueCopy

  1. .align-self-stretch
    align-self: stretch
  2. .align-self-start
    align-self: start
  3. .align-self-end
    align-self: end
  4. .align-self-center
    align-self: center
  5. .align-self-baseline
    align-self: baseline

Justify-content

ClassValueCopy

  1. .justify-content-start
    justify-content: start
  2. .justify-content-end
    justify-content: end
  3. .justify-content-center
    justify-content: center
  4. .justify-content-between
    justify-content: between
  5. .justify-content-around
    justify-content: around
  6. .justify-content-evenly
    justify-evenly: between

Visual examples

.justify-content-start

Item 1
Item 2
Item 3
Item 4

.justify-content-end

Item 1
Item 2
Item 3
Item 4

.justify-content-center

Item 1
Item 2
Item 3
Item 4

.justify-content-between

Item 1
Item 2
Item 3
Item 4

.justify-content-around

Item 1
Item 2
Item 3
Item 4

.justify-content-evenly

Item 1
Item 2
Item 3
Item 4

Flex-direction

ClassValueCopy

  1. .flex-row
    flex-direction: row
  2. .flex-column
    flex-direction: column
  3. .flex-row-reverse
    flex-direction: row-reverse
  4. .flex-column-reverse
    flex-direction: column-reverse

Visual examples

.flex-row

Item 1
Item 2
Item 3
Item 4

The default is flex-direction: row which is “left to right” along X axis. This is the default and you do need to declare this (unless you do). The following classes allow permutations:

.flex-column

Item 1
Item 2
Item 3
Item 4

Changes the main axis to Y (from the default X asis) i.e. “top to bottom”.

.flex-row-reverse

Item 1
Item 2
Item 3
Item 4

Reverses the X axis to “right to left”.

.flex-column-reverse

Item 1
Item 2
Item 3
Item 4

Reverses the Y axis to “bottom to top”.

Other flex utility classes

Order

Apply on flex items (as opposed to .flex-row-reverse which is applied to flex containers).

ClassValueCopy

  1. .order-first
    order: -1
  2. .order-1
    order: 1
  3. .order-2
    order: 2
  4. .order-3
    order: 3
  5. .order-4
    order: 4
  6. .order-5
    order: 5
  7. .order-last
    order: 6

Grow and shrink

ClassValueCopy

  1. .flex-grow-0
    flex-grow: 0
  2. .flex-grow-1
    flex-grow: 1
  3. .flex-shrink-0
    flex-shrink: 0
  4. .flex-shrink-1
    flex-shrink: 1

Wrap

ClassValueCopy

  1. .flex-wrap
    flex-wrap: wrap
  2. .flex-nowrap
    flex-wrap: nowrap
  3. .flex-wrap-reverse
    flex-wrap: reverse