Skip to content

Flexbox

Flexbox is a powerful layout model that provides an efficient way to distribute space and align items within a container. To start using flexbox, add the is-flex class to a container element.

Flex Direction

These utilities control the direction in which flex items are placed in the flex container.

ClassCSSDescription
is-flex-rowflex-direction: row;Items are placed horizontally, from left to right. (Default)
is-flex-row-reverseflex-direction: row-reverse;Items are placed horizontally, from right to left.
is-flex-colflex-direction: column;Items are placed vertically, from top to bottom.
is-flex-col-reverseflex-direction: column-reverse;Items are placed vertically, from bottom to top.

Example: A common use case is creating a vertical layout for a card's content.

html
<div class="is-flex is-flex-col">
  <span>Item 1</span>
  <span>Item 2</span>
  <span>Item 3</span>
</div>

Justify Content

These utilities define how the browser distributes space between and around content items along the main axis.

ClassCSSDescription
is-justify-startjustify-content: flex-start;Items are packed toward the start of the flex-direction.
is-justify-endjustify-content: flex-end;Items are packed toward the end of the flex-direction.
is-justify-centerjustify-content: center;Items are centered along the line.
is-justify-betweenjustify-content: space-between;Items are evenly distributed; the first item is on the start line, the last on the end line.
is-justify-aroundjustify-content: space-around;Items are evenly distributed with equal space around them.
is-justify-evenlyjustify-content: space-evenly;Items are distributed so that the spacing between any two items is equal.

Example: Centering items inside a container.

html
<div class="is-flex is-justify-center">
  <div>Item 1</div>
  <div>Item 2</div>
</div>

Align Items

These utilities define how flex items are laid out along the cross axis.

ClassCSSDescription
is-items-startalign-items: flex-start;Items are placed at the start of the cross axis.
is-items-endalign-items: flex-end;Items are placed at the end of the cross axis.
is-items-centeralign-items: center;Items are centered in the cross-axis.
is-items-baselinealign-items: baseline;Items are aligned such as their baselines align.
is-items-stretchalign-items: stretch;Stretch to fill the container (still respects min/max-width). (Default)

Example: Vertically centering items in a navigation bar.

html
<nav class="is-flex is-h-16 is-items-center">
  <div>Logo</div>
  <div>Links</div>
</nav>

Flex Wrap

These utilities control whether flex items are forced onto one line or can wrap onto multiple lines.

ClassCSSDescription
is-flex-nowrapflex-wrap: nowrap;All flex items will be on one line. (Default)
is-flex-wrapflex-wrap: wrap;Flex items will wrap onto multiple lines, from top to bottom.
is-flex-wrap-reverseflex-wrap: wrap-reverse;Flex items will wrap onto multiple lines from bottom to top.

Example: Creating a responsive grid of tags that wraps on smaller screens.

html
<div class="is-flex is-flex-wrap is-gap-2">
  <span class="tag">Tag 1</span>
  <span class="tag">Tag 2</span>
  <span class="tag">Tag 3</span>
  <!-- ... more tags -->
</div>

Align Content

Use these utilities to align a flex container’s lines when there is extra space in the cross-axis, such as when is-flex-wrap is used. This property has no effect on single-line flex containers.

ClassCSSDescription
is-content-startalign-content: flex-start;Lines packed to the start of the container.
is-content-endalign-content: flex-end;Lines packed to the end of the container.
is-content-centeralign-content: center;Lines packed to the center of the container.
is-content-betweenalign-content: space-between;Lines evenly distributed; the first line is at the start, the last at the end.
is-content-aroundalign-content: space-around;Lines evenly distributed with equal space around each line.
is-content-evenlyalign-content: space-evenly;Lines are evenly distributed with equal space around them.

Flex Grow & Shrink

Control how flex items grow to fill available space or shrink to fit.

ClassCSSDescription
is-flex-grow-1flex-grow: 1;The item will grow to fill any available space.
is-flex-grow-0flex-grow: 0;The item will not grow. (Default)
is-flex-shrink-1flex-shrink: 1;The item will shrink if necessary. (Default)
is-flex-shrink-0flex-shrink: 0;The item will not shrink.

Example: Creating a layout where one item takes up all remaining space.

html
<div class="is-flex">
  <div class="sidebar">Sidebar</div>
  <div class="main-content is-flex-grow-1">Main content grows to fill space</div>
</div>

Align Self

Override the container's align-items property for individual flex items.

ClassCSSDescription
is-self-startalign-self: flex-start;Aligns the item to the start of the cross axis.
is-self-endalign-self: flex-end;Aligns the item to the end of the cross axis.
is-self-centeralign-self: center;Centers the item on the cross axis.
is-self-baselinealign-self: baseline;Aligns the item's baseline with the other items.
is-self-stretchalign-self: stretch;Stretches the item to fill the container's cross size.

Example:

html
<div class="is-flex is-items-start">
  <div>Item 1</div>
  <div class="is-self-end">This item is aligned to the end</div>
  <div>Item 3</div>
</div>