CSS Grid Generator: Visual Layout with Areas & Tailwind
Set columns, rows, gap and named areas visually and copy the layout as CSS, HTML or Tailwind, plus mobile-first media queries and 7 presets.
Updated November 2026
Reviewed by Rafael Duarte
<div class="grid grid-cols-3 grid-rows-[repeat(2,auto)] gap-4">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</div> Click an item in the canvas to edit its column and row spans.
auto-fill creates as many tracks as possible and keeps the empty ones — auto-fit collapses empty tracks so items stretch to fill the row. Drag the slider to see the difference.
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));How to use this CSS Grid generator
From blank grid to production code in under a minute
1. Pick a preset or set your tracks
Under Quick Presets, pick Holy Grail, Dashboard, Card Grid or one of four more, or drag the Columns and Rows sliders (1 to 12) to start from scratch.
2. Adjust item spans or named areas
In Item Spans mode, click an item on the canvas to set its column and row span and its start line. In Named Areas mode, type names straight into the matrix and watch the layout update live.
3. Copy the code
Open the Tailwind, CSS, HTML or Responsive tab (one at a time) and click Copy. The download button saves grid.css with the plain CSS, or the media queries if the Responsive tab is open.
What this CSS grid layout generator does
Four code tabs plus a visual editor for named areas
Four outputs: Tailwind, CSS, HTML and Responsive
The same layout as Tailwind classes, a plain CSS rule set, ready HTML markup with its styles, or mobile-first media queries. Switch tabs to change format; you never rebuild the grid.
grid-template-areas editor
Type area names directly into the matrix and the preview rearranges itself in real time, so you don't have to memorize the string-map syntax. Empty cells become ..
Auto-fill vs auto-fit lab
A separate demo with sliders for item count and minimum track width plus an auto-fill/auto-fit switch, so you can see the difference instead of reading about it. It's for learning; the line it shows isn't part of the generated code.
Responsive tab
Writes mobile-first media queries at 640px and 1024px. In Item Spans mode it uses the column counts you set per breakpoint; in Named Areas mode it stacks the areas in one column and applies your full layout from 1024px up.
Examples
What a few common setups produce
When you'll reach for this tool
The most common scenarios among people who use it
Page layouts (Holy Grail)
Header, footer, and three columns in between — the preset generates the whole structure in one click.
Admin dashboards
A fixed sidebar plus flexible content areas — named areas keep the CSS readable as the layout grows more complex.
Product or card galleries
For a gallery that reflows on its own, repeat(auto-fill, minmax(250px, 1fr)) does it without breakpoints. Try the behavior in the auto-fill vs auto-fit lab, then write that line yourself: the generator's tabs output fixed column counts, or use the Responsive tab for breakpoint-based columns.
Tailwind projects
The Tailwind tab outputs grid-cols-*, col-span-*, and arbitrary values ready to paste into React, Vue, or Svelte components.
Common CSS Grid mistakes
Non-rectangular named areas
An L-shaped area silently invalidates the entire grid-template-areas declaration and the browser falls back to automatic placement with no console warning.
Confusing fr with %
1fr is a fraction of the leftover space after fixed tracks and gaps are accounted for; % is a fraction of the total container width — mixing the two with gap causes overflow.
A span larger than the track count
col-span-4 on a 3-column grid doesn't clip — it forces the browser to create an implicit fourth column, which shifts everything after it.
Why use this CSS grid generator
The visual grid-template-areas editor and the auto-fill vs auto-fit lab turn the two parts of CSS Grid that confuse developers most into something you can see and click through instead of memorize.
The Responsive tab writes mobile-first media queries at 640px and 1024px from the layout you arranged, one less manual step between prototyping and shipping.
Not sure the layout even calls for Grid? CSS Grid vs Flexbox covers when each one fits, How to Build Responsive Layouts Without Frameworks shows Grid alongside clamp() and container queries, and for one-dimensional rows like navbars the flexbox generator is the quicker tool.
auto-fill vs. auto-fit
The most common point of confusion in CSS Grid
Frequently asked questions
Both create as many tracks as will fit using repeat(). When the items don't fill the whole row, auto-fill keeps the leftover tracks empty, while auto-fit collapses those empty tracks to zero width and stretches the existing items to fill the space. They behave identically when there are enough items to fill every track.
fr stands for a fraction of the space left over after all fixed-size tracks and gaps have been placed. In a 800px container, grid-template-columns: 200px 1fr 1fr results in 200px, 300px, and 300px — the two 1fr tracks split whatever remained.
Use grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)) — it creates as many columns of at least 250px as the container can hold, and the count adjusts automatically as the viewport resizes. No breakpoints required.
It defines the layout as a text map: each quoted string is one row, each word inside it names an area, and a period marks an empty cell. Every named area has to form a rectangle, or the whole declaration is ignored by the browser. In the editor, names are lowercased and spaces become hyphens, so "Main Content" turns into main-content, and empty cells become ..
Yes, without a plugin. In Named Areas mode, the Tailwind tab writes the template as an arbitrary property, such as [grid-template-areas:'header_header'_'sidebar_main'], and gives each child [grid-area:main]-style classes. Underscores stand in for spaces, as Tailwind's arbitrary values require.
Yes — the Tailwind tab converts your setup in real time into classes like grid-cols-3, gap-4, and col-span-2. Custom tracks that don't map to a default scale value become Tailwind's arbitrary-value syntax, such as grid-cols-[200px_1fr_200px].
The most common cause is a non-rectangular area — every named area must form a solid rectangle in the text map, or the browser discards the entire declaration and falls back to auto-placement. Check that every row referencing the same area name has the same width and shape.
References
The definitive reference for every Grid property, with browser compatibility notes.
The most widely used visual cheatsheet for container and item properties.
Google's interactive course covering tracks, areas, and auto-placement in depth.
Related Tools
- Color Contrast Checker: WCAG AA/AAA & Color Blindness Design Check if text and background pass WCAG 2.2 AA and AAA, get the nearest passing text color and preview 4 types of color blindness. Free, in your browser.
- HEX to RGB Converter with HSL & CMYK Values Design Paste a HEX code and copy its RGB, HSL and CMYK values instantly, with 4 harmony colors, a contrast check against white and CSS palette export.
- Color Scheme Generator: Complementary, Triadic & Analogous Design Pick a base color and get 5 harmonious colors: analogous, monochromatic, complementary, triadic or tetradic. Preview them on a site, export CSS or JSON.
- Color Palette from Image: Extract HEX, RGB & HSL Codes Design Upload a photo or logo and extract 3 to 12 dominant colors as HEX, RGB and HSL. Export CSS variables, Tailwind, JSON or PNG. Nothing leaves your browser.
- CSS Box Shadow Generator: Tailwind, Neumorphism & Glass Design Create CSS box shadows with a live preview and ready-made presets, or switch to neumorphism and glassmorphism. Copy as CSS, a Tailwind class or a variable.