cssgridgenerator
Layout patterns

CSS Grid layout patterns

46 layouts that already exist in the wild — a holy grail page, a kanban board, a checkout, a magazine front. Each one opens in the editor with its breakpoints set up, so you change the tracks and copy CSS that has the media queries already written.

New to the properties? The CSS Grid cheat sheet covers each one and why you would reach for it, and the grid generator starts from a blank layout instead of a pattern.

Page shells

Where the header, navigation, content and footer sit. Every other pattern lives inside one of these.

Editorial

Layouts whose job is reading — articles, galleries, front pages and the hierarchy that makes them scannable.

Marketing sections

The bands a landing page is assembled from. They stack rather than nest, so mix them freely.

Commerce

Category, product, cart and checkout — the four pages that carry a shop.

App UI

Layouts with state behind them, where the real constraint is usually which panes scroll.

Picking a pattern

The five groups answer different questions. Page shells decide where the header, navigation and footer live — start here, because every other pattern sits inside one. Editorial covers anything whose job is reading: articles, galleries, front pages. Marketing sections are the bands a landing page is assembled from, and they stack rather than nest. Commerce and App UI are the layouts with real state behind them, where the interesting constraint is usually which panes scroll.

Every pattern here is responsive by construction rather than by retrofit: the layout is drawn at each breakpoint, so the exported CSS contains only the properties that actually differ between them. That is the same output you get from the grid generator, and it converts to Tailwind, a React, Vue or Svelte component, or a shadcn-style compound component, depending on what your project uses.

Already have the CSS? The CSS Grid visualizer reads a stylesheet back into this same editor, which is the quickest way to find out why a grid you inherited does not behave.

Frequently asked questions

How do I center a grid in CSS?
Use justify-content: center on the grid container to centre the whole grid inside it, and margin-inline: auto with a max-width to centre the container in the page. These are different jobs: the first moves the tracks within the container, the second moves the container itself.
How do I center items inside a CSS grid?
Set place-items: center on the container. That is shorthand for align-items plus justify-items, and it centres every item inside its own cell on both axes. For a single item, use place-self: center on that item instead.
How do I make a CSS grid responsive?
Use grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) and it reflows at every width with no media queries at all. Add breakpoints only when the exact column count matters, or when the layout has to change shape rather than just wrap.
When should I use CSS Grid instead of Flexbox?
Use Grid when things must line up in two directions at once, and Flexbox when content flows along one axis. A page skeleton or dashboard is Grid; a navbar or row of buttons is Flexbox. They nest: Grid for the page, Flexbox inside the cells.
What is the fr unit in CSS Grid?
fr is a fraction of the space left over after fixed tracks and gaps are subtracted. In grid-template-columns: 200px 1fr 2fr, the 200px is taken out first, then the remainder splits three ways — one part to the second column, two to the third. It is not a percentage of the container.