Building a grid

Auto placement

Auto placement controls items that have no set position, and tracks the browser creates beyond your grid.

The three settings #

PropertyWhat it does
grid-auto-flowThe direction unplaced items fill the grid: row (the default), column, or with dense to fill earlier gaps.
grid-auto-columnsThe size of columns the browser adds when content goes past your last column.
grid-auto-rowsThe size of rows the browser adds when content goes past your last row. Common for card lists of unknown length, for example minmax(120px, auto).

Set them in the Auto placement section. The size boxes accept one or more track sizes separated by spaces, such as 100px or 100px 200px.

Why the preview doesn't change #

GridFlow gives every item an explicit position, so none of them are placed automatically, and the grid never grows past the tracks you set. These settings are still written into the CSS and applied to the preview. They take effect in your own project when you add more children than the grid places, for example a list of cards rendered from data.

Example: a growing card list #

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: auto;
  gap: 20px;
  grid-auto-rows: minmax(120px, auto);
}

Any cards beyond the first row wrap onto new rows that are at least 120px tall.