Skip to content

Flexbox

Sass mixins

MixinCSS properties
flexdisplay: flex
inline-flexdisplay: inline-flex
flex-rowflex-direction: row
flex-colflex-direction: column
f-rowAlias for flex-row
f-colAlias for flex-col
flex-row-reverseflex-direction: row-reverse
flex-col-reverseflex-direction: column-reverse
flex-wrapflex-wrap: wrap
flex-nowrapflex-wrap: nowrap
flex-wrap-reverseflex-wrap: wrap-reverse
growflex-grow: 1
no-growflex-grow: 0
shrinkflex-shrink: 1
no-shrinkflex-shrink: 0
justify-startjustify-content: flex-start
justify-endjustify-content: flex-end
justify-centerjustify-content: center
justify-betweenjustify-content: space-between
justify-aroundjustify-content: space-around
justify-evenlyjustify-content: space-evenly
items-startalign-items: flex-start
items-endalign-items: flex-end
items-centeralign-items: center
items-baselinealign-items: baseline
items-stretchalign-items: stretch
self-autoalign-self: auto
self-startalign-self: flex-start
self-endalign-self: flex-end
self-centeralign-self: center
self-baselinealign-self: baseline
self-stretchalign-self: stretch
content-startalign-content: flex-start
content-endalign-content: flex-end
content-centeralign-content: center
content-betweenalign-content: space-between
content-aroundalign-content: space-around
content-evenlyalign-content: space-evenly

Utility classes

Flex Display

ClassProperty
flexdisplay: flex
inline-flexdisplay: inline-flex

Flex Direction

ClassProperty
flex-row, f-rowflex-direction: row
flex-col, f-colflex-direction: column
flex-row-reverse, f-row-reverseflex-direction: row-reverse
flex-col-reverse, f-col-reverseflex-direction: column-reverse

Flex Wrap

ClassProperty
flex-wrapflex-wrap: wrap
flex-nowrapflex-wrap: nowrap
flex-wrap-reverseflex-wrap: wrap-reverse

Flex Grow and Shrink

ClassProperty
growflex-grow: 1
no-grow, grow-0flex-grow: 0
shrinkflex-shrink: 1
no-shrink, shrink-0flex-shrink: 0

Justify Content

ClassProperty
justify-startjustify-content: flex-start
justify-endjustify-content: flex-end
justify-centerjustify-content: center
justify-betweenjustify-content: space-between
justify-aroundjustify-content: space-around
justify-evenlyjustify-content: space-evenly

Align Items

ClassProperty
items-startalign-items: flex-start
items-endalign-items: flex-end
items-centeralign-items: center
items-baselinealign-items: baseline
items-stretchalign-items: stretch

Align Self

ClassProperty
self-autoalign-self: auto
self-startalign-self: flex-start
self-endalign-self: flex-end
self-centeralign-self: center
self-baselinealign-self: baseline
self-stretchalign-self: stretch

Align Content

ClassProperty
content-startalign-content: flex-start
content-endalign-content: flex-end
content-centeralign-content: center
content-betweenalign-content: space-between
content-aroundalign-content: space-around
content-evenlyalign-content: space-evenly

Flexbox examples

Sass mixins

html
<style lang="scss">
  @use "crayon-css" as crayon;

  .site-nav {
    @include crayon.flex;
    @include crayon.items-center;
    @include crayon.justify-between;
    @include crayon.p(4);

    .links {
      @include crayon.flex;
      @include crayon.gap(4);
    }
  }
</style>

Utility classes

html
<nav class="site-nav flex items-center justify-between p-4">
  <a href="/">Logo</a>
  <div class="links flex gap-4">
    <a href="/about">About</a>
    <a href="/contact">Contact</a>
  </div>
</nav>

Sass functions

html
<style lang="scss">
  @use "crayon-css" as crayon;

  .site-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: crayon.size(4);

    .links {
      display: flex;
      gap: crayon.size(4);
    }
  }
</style>

CSS Variables

css
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--size-4);
}

.site-nav .links {
  display: flex;
  gap: var(--size-4);
}