How to use the CSS grid generator
- Start from a preset: holy grail, sidebar layouts, app shell, dashboards, magazine, bento or auto-fill card grids.
- Set the tracks. Type a size for each column and row. Invalid sizes are highlighted and ignored, so the output stays valid. Add or remove columns and rows as needed.
- Paint the areas. Pick an area name (or create one), then click cells, or Tab to them and press Enter, to assign them. Use Empty for gaps.
- Adjust the gaps between columns and rows.
- For card grids, switch to Auto-fill cards and set the minimum card width.
- Export CSS, HTML, SCSS, Tailwind or React.
How it works
.layout {
display: grid;
grid-template-columns: 220px 1fr 1fr;
grid-template-rows: auto 1fr auto;
grid-template-areas:
"header header header"
"sidebar main main"
"footer footer footer";
gap: 16px;
}
.layout__header { grid-area: header; }
The fr unit shares the free space. auto rows fit their content. minmax(0, 1fr) stops long words or wide images from stretching a column.
Worked examples
Example 1: a blog with a reading column
Load Blog post. The middle column is minmax(0, 680px) with flexible columns either side, which centres the article at a comfortable line length while the header and footer span the full width.
Example 2: a dashboard
Load Dashboard: a header, four KPI tiles and a large chart beside a table. Repaint the cells to give the table more room, and check that every area stays a rectangle.
Example 3: a product listing
Load Cards auto-fill with a 220px minimum. Cards wrap from four columns to one as the screen narrows, with no media queries at all.
Making grids responsive
For named-area layouts, redefine grid-template-columns and grid-template-areas inside a media query. On phones, a single column with areas stacked in reading order is usually best.
Common mistakes
- Fixed pixel columns on mobile: combine them with a media query, or use
minmax(). - Forgetting
min-width: 0: grid items default tomin-width: auto, so long content can overflow.minmax(0, 1fr)tracks avoid this. - Reordering content visually: keep the HTML order meaningful.