Skip to content

Justify Content

Distributes space between and around items along the main axis of a flex container and the inline axis of a grid container.

Class names

ClassDescription
justify-startjustify-content: flex-start;
justify-centerjustify-content: center;
justify-endjustify-content: flex-end;
justify-end-safejustify-content: safe flex-end;
justify-betweenjustify-content: space-between;
justify-aroundjustify-content: space-around;
justify-evenlyjustify-content: space-evenly;
justify-stretchjustify-content: stretch;

Examples

Start

html
<div class="flex justify-start gap-2">
  <span class="bg-primary p-2 text-primary-foreground">1</span>
  <span class="bg-primary p-2 text-primary-foreground">2</span>
  <span class="bg-primary p-2 text-primary-foreground">3</span>
</div>

Center

html
<div class="flex justify-center gap-2">
  <span class="bg-primary p-2 text-primary-foreground">1</span>
  <span class="bg-primary p-2 text-primary-foreground">2</span>
  <span class="bg-primary p-2 text-primary-foreground">3</span>
</div>

End

html
<div class="flex justify-end gap-2">
  <span class="bg-primary p-2 text-primary-foreground">1</span>
  <span class="bg-primary p-2 text-primary-foreground">2</span>
  <span class="bg-primary p-2 text-primary-foreground">3</span>
</div>

End safe

html
<div class="vbox gap-2">
  <label x-h-label>End</label>
  <div class="flex justify-end gap-2 overflow-hidden">
    <span class="bg-primary px-12 py-2 text-primary-foreground">1</span>
    <span class="bg-primary px-12 py-2 text-primary-foreground">2</span>
    <span class="bg-primary px-12 py-2 text-primary-foreground">3</span>
    <span class="bg-primary px-12 py-2 text-primary-foreground">4</span>
    <span class="bg-primary px-12 py-2 text-primary-foreground">5</span>
    <span class="bg-primary px-12 py-2 text-primary-foreground">6</span>
    <span class="bg-primary px-12 py-2 text-primary-foreground">7</span>
    <span class="bg-primary px-12 py-2 text-primary-foreground">8</span>
  </div>
  <label x-h-label>End safe</label>
  <div class="flex justify-end-safe gap-2 overflow-hidden">
    <span class="bg-primary px-12 py-2 text-primary-foreground">1</span>
    <span class="bg-primary px-12 py-2 text-primary-foreground">2</span>
    <span class="bg-primary px-12 py-2 text-primary-foreground">3</span>
    <span class="bg-primary px-12 py-2 text-primary-foreground">4</span>
    <span class="bg-primary px-12 py-2 text-primary-foreground">5</span>
    <span class="bg-primary px-12 py-2 text-primary-foreground">6</span>
    <span class="bg-primary px-12 py-2 text-primary-foreground">7</span>
    <span class="bg-primary px-12 py-2 text-primary-foreground">8</span>
  </div>
</div>

Between

html
<div class="flex justify-between">
  <span class="bg-primary p-2 text-primary-foreground">1</span>
  <span class="bg-primary p-2 text-primary-foreground">2</span>
  <span class="bg-primary p-2 text-primary-foreground">3</span>
</div>

Around

html
<div class="flex justify-around">
  <span class="bg-primary p-2 text-primary-foreground">1</span>
  <span class="bg-primary p-2 text-primary-foreground">2</span>
  <span class="bg-primary p-2 text-primary-foreground">3</span>
</div>

Evenly

html
<div class="flex justify-evenly">
  <span class="bg-primary p-2 text-primary-foreground">1</span>
  <span class="bg-primary p-2 text-primary-foreground">2</span>
  <span class="bg-primary p-2 text-primary-foreground">3</span>
</div>