Building a grid

Template areas

Template areas describe your layout as a map of names. They make the CSS easy to read and easy to change later.

Turn on named areas #

Tick Use named grid areas in the Template areas section. GridFlow then:

  • adds grid-template-areas to the grid container,
  • gives each item grid-area: name instead of line numbers,
  • shows the area map under the checkbox.

How areas are named and placed #

Each item is one area. Its name is the item's class name, which comes from its label (see Label and class name). Its position on the grid sets which cells the area covers. To change an area, move or resize the item.

.grid {
  display: grid;
  grid-template-columns: 200px 1fr 200px;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "header header header"
    "nav    main   aside"
    "footer footer footer";
  gap: 16px;
}

.header {
  grid-area: header;
}

Names are padded with spaces so the columns line up. Browsers ignore the extra spaces.

Empty cells #

Cells that no item covers are written as a dot (.), which CSS reads as an unnamed cell.

Why areas are always valid #

CSS requires every named area to be a single rectangle, with no name used in two separate places. In GridFlow every item is a rectangle, items can't overlap, and names are made unique automatically, so the generated grid-template-areas is always valid.