Flexbox & GridGrid Auto Flow

Grid Auto Flow

Controls the automatic placement of grid elements.

Widely available

This feature is well established and works across many devices and browser versions.

Chrome
Edge
Firefox
Safari
ClassStyle
gaf-cgrid-auto-flow: column;
gaf-cdgrid-auto-flow: column dense;
gaf-dgrid-auto-flow: dense;
gaf-rgrid-auto-flow: row;
gaf-rdgrid-auto-flow: row dense;

Row

Initial value

The items will be placed in the grid by filling each row before moving to the next one.

A
B
C
D
E
<div class="d-g g-4 gaf-r gtc-3 gtr-3 ta-c tc-white">
<div class="bg-indigo-8 gc-s-2 p-4 tc-indigo-5">A</div>
<div class="bg-indigo-8 gc-s-2 p-4 tc-indigo-5">B</div>
<div class="bg-indigo p-4">C</div>
<div class="bg-indigo-8 p-4 tc-indigo-5">D</div>
<div class="bg-indigo-8 p-4 tc-indigo-5">E</div>
</div>

Column

The items will be placed in the grid by filling each column before moving to the next one.

A
B
C
D
E
<div class="d-g g-4 gaf-c gtc-3 gtr-3 ta-c">
<div class="bg-indigo-8 gc-s-2 p-4 tc-indigo-5">A</div>
<div class="bg-indigo-8 gc-s-2 p-4 tc-indigo-5">B</div>
<div class="bg-indigo p-4 tc-white">C</div>
<div class="bg-indigo-8 p-4 tc-indigo-5">D</div>
<div class="bg-indigo-8 p-4 tc-indigo-5">E</div>
</div>

Dense

The items will be placed in the grid in a way that fills in gaps as efficiently as possible.

A
B
C
D
E
<div class="d-g g-4 gaf-d gtc-3 gtr-3 ta-c tc-white">
<div class="bg-indigo-8 gc-s-2 p-4 tc-indigo-5">A</div>
<div class="bg-indigo-8 gc-s-2 p-4 tc-indigo-5">B</div>
<div class="bg-indigo p-4">C</div>
<div class="bg-indigo-8 p-4 tc-indigo-5">D</div>
<div class="bg-indigo-8 p-4 tc-indigo-5">E</div>
</div>

Row Dense

The items will be placed in the grid by filling each row first, while also attempting to fill any gaps efficiently.

A
B
C
D
<div class="d-g gaf-rd g-4 ta-c tc-white">
<div class="bg-indigo p-4">A</div>
<div class="bg-indigo p-4">B</div>
<div class="bg-indigo p-4">C</div>
<div class="bg-indigo p-4">D</div>
</div>

Using utility variants

Learn how to override existing utilities based on the user's screen size or other factors, such as hover states.

Targeting different viewports

You can combine responsive breakpoints like sm:gaf-*, md:gaf-*, lg:gaf-*, and xxl:gaf-* to allow targeting specific utilities in different viewports.

Targeting hover states

Alternatively, you can apply :hover by using h:gaf-* utility to override elements and change their values when hovering over them.