#1537·pure

RFC: Pure Grids v4 (CSS Grid, `gap`, and auto-fitting layouts)

Author: redonkulusCreated Sep 29, 2026Updated Sep 30, 2026

Summary

In Pure v4 we'd like to build Pure Grids on CSS Grid. The class names you use today (pure-g, pure-u-1-2, pure-u-md-1-3, …) would stay the same. On top of them we'd add:

  • Built-in gutters with gap, set by a single CSS custom property
  • An auto-fitting grid that makes responsive card layouts with no breakpoints
  • Optional container-query units, so a component can respond to its own width instead of the viewport's

We'd like your feedback before we start. Please comment with what works for you, what worries you, and how you use Grids today.

Motivation

CSS Grid, gap, minmax(), container queries and subgrid are now supported in every evergreen browser. They give us a chance to extend Pure Grids in ways many of you have asked for, especially gutters, while keeping the small footprint and readable fraction class names that make Pure Grids easy to use.

Proposal

1. Grid container

css
.pure-g {
    display: grid;
    grid-template-columns: repeat(var(--pure-grid-columns, 120), minmax(0, 1fr));
    gap: var(--pure-grid-gap, 0);
    align-content: start;
}

120 columns is the least common multiple of 5 and 24. Every existing fraction (fifths, the 24ths, and everything in between) maps to an exact whole number of columns.

2. Grid units

Units keep their names and map to column spans:

Class Spans
pure-u-1 / pure-u-24-24 full row
pure-u-1-2 60 of 120
pure-u-1-3 40 of 120
pure-u-1-5 24 of 120
pure-u-7-24 35 of 120

Responsive units (pure-u-sm-*, pure-u-md-*, pure-u-lg-*, pure-u-xl-*, …) work the same way at the same breakpoints.

3. Gutters

The default gap is 0, so layouts look the same unless you opt in:

css
.my-layout { --pure-grid-gap: 1rem; }

You could also use a small set of preset classes, for example pure-g-gap-sm, pure-g-gap-md and pure-g-gap-lg (see the open questions).

4. Auto-fitting grid (new)

xml
<div class="pure-g-auto" style="--pure-grid-min: 16rem">
    <div>…</div> <div>…</div> <div>…</div>
</div>

Items fill the row at no less than --pure-grid-min each and wrap on their own. You don't need breakpoint classes.

5. Container-query units (new, optional add-on)

A pure-g-container wrapper plus classes like pure-u-c-md-1-2 that respond to the wrapper's width rather than the viewport's. This would ship as a separate file (grids-container.css) so nobody pays for it unless they use it.

6. generateGrids()

require('purecss').generateGrids(units, options) keeps its signature and produces span-based output. It gets a new columns option. By default, columns is calculated from the units you request.

Migration guide

Most layouts that use only pure-g with pure-u-* fraction classes need no changes.

  1. Update Pure to v4 and include grids.css / grids-responsive.css as you do today.
  2. Direct children of .pure-g without a pure-u-* fraction class will take up a full row. Add a fraction class (e.g. pure-u-1-2) to any child that should share a row.
  3. pure-u with no fraction (content-width units): if you depended on a unit shrinking to fit its content, switch that container to pure-g-auto, or give the unit an explicit fraction. (Open question below.)
  4. Custom widths on units (for example .sidebar { width: 30%; } on a pure-u element) should become a span:
    css
    .sidebar { grid-column: span 36; } /* 30% of 120 */
  5. Alignment inside a row: replace vertical-align on units with align-self (start, center, end). Replace justify-content on .pure-g with justify-items, or use grid-column-start on a unit to offset it.
  6. Reordering: order keeps working. You can also use grid-column / grid-row placement directly.
  7. Gutters: if you add spacing with an inner wrapper (like .l-box in the docs) or with padding, you can leave it as is. Optionally, remove it and set --pure-grid-gap instead.
  8. Custom grids built with generateGrids(): rebuild your CSS after upgrading. If you previously set includeOldIEWidths, that option is no longer used and can be removed.
  9. Test at each breakpoint you use, particularly layouts with mixed denominators in one row (e.g. 1-5 next to 4-5, or 1-3 next to 7-24).

Rollout

  • Publish an opt-in preview file (grids-next.css) in a 3.x minor release so you can try it side by side before v4.
  • Update the docs and the example layouts on the website to use the new grid, gutters and auto grid.
  • Ship v4 with a changelog that links to this migration guide.

Open questions (feedback wanted)

  1. Content-width units: how many of you use a bare pure-u to size units to their content? Should v4 keep a content-width option, and in what form?
  2. Gap presets: is --pure-grid-gap enough, or would preset classes (pure-g-gap-sm/md/lg) help? What sizes?
  3. Breakpoints: which responsive prefixes do you actually use? Should xxl, xxxl and x4k stay in the default build or become opt-in?
  4. Container queries: should container-query units be in the default build or stay a separate add-on?
  5. Anything else? Tell us about layouts you build with Pure Grids today that you think might not fit this model. Code samples are very welcome.