Flex Grids (Flexbox Grids)
CSS Grid is a powerful layout system, but it has one weakness for some users. Grids with an unbalanced number of items must remain left-aligned at all times.

Some users prefer unbalanced grid items to be centered at the bottom of the grid, like this:
The only programmatic solution is to use Flexbox. But, Flexbox isn't designed to create grid layouts, so a lot of math is involved to get it right, especially when you want to use gap to space items out.
This is where Automatic.css "Flex Grid" comes in.
Flex Grid is a feature unique to Automatic.css that allows users to create grid layouts where unbalanced items can be centered or stretched.
All the complicated math and setup is done for you. You can even adjust the gap size without issue.
Using the Flex Grid Recipe 4.0.2+
In Bricks and Gutenberg the ?flex-grid recipe is available since ACSS 4.0.2. Type it on its own line in the parent container's CSS:
?flex-grid;
It expands to a complete %root% { … } block, and you're all set. Your unbalanced items will be centered at the bottom of the grid by default.
Locally Scoped Variables
The flex grid recipe provides three locally scoped variables you can use to customize the behavior:
| Variable | Default | Description |
|---|---|---|
--gap | var(--grid-gap, 1.5rem) | Controls the gap between grid items |
--columns | 3 | Sets the number of columns |
--stretch | 0 | Controls whether unbalanced items stretch (set to 1 to enable) |
Example with Custom Variables
Change the values at the top of the expanded block:
%root% {
--gap: var(--space-l);
--columns: 4;
--stretch: 1; /* Stretch unbalanced items */
/* … rest of the recipe … */
}
Responsive Behavior
The recipe includes default media queries for responsive behavior:
@media (max-width: 900px) {
--columns: 2;
}
@media (max-width: 600px) {
--columns: 1;
}
To change the responsive behavior, edit the media queries inside the expanded block:
%root% {
--columns: 5;
/* … rest of the recipe … */
@media (max-width: 1200px) {
--columns: 3;
}
@media (max-width: 768px) {
--columns: 2;
}
@media (max-width: 480px) {
--columns: 1;
}
}
Changes From 3.x
In ACSS 4.0:
- Flex Grid utility classes (
.flex-grid--1through.flex-grid--6and all breakpoint variants) have been replaced with the?flex-gridrecipe. - The recipe provides locally scoped variables (
--gap,--columns,--stretch) for customization. - Responsive behavior is now controlled via media queries rather than breakpoint classes.