Grid Morph
A tile mosaic that stacks in a column inside 200 px, goes to two columns at 220 px and, at 300 px, moves to three columns while giving the first tile the room of four. CSS only.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Utilities has 43 effects, including 3 free. Explore the category →
3 usage examples



How it works
.grm-grid is a CSS grid: one column, fixed 60 px rows (grid-auto-rows), 8 px between tiles, 12 px around. Each .grm-item centres its content and gets one of six tints (purple, pink, cyan, amber, green, red at 15 %), handed out by :nth-child(6n+…): the seventh tile takes the first one's colour again.
The root .fx-0754-root carries container: grm / inline-size. At 220 px wide, @container grm writes repeat(2, 1fr); at 300 px, repeat(3, 1fr), and the .grm-item:first-child rule stretches the first tile over two columns and two rows. With six tiles this makes a full square of three rows: the big one, two small ones to its right, three underneath. The same threshold reveals .grm-span, a bit of text kept hidden in the first tile until then.
Height changes with the column count: 424 px as a column, 220 px at two as at three columns for six tiles. The switch is abrupt: the component has neither transition nor script, tiles jump from one layout to the next.
Accessibility
- Order kept: the grid moves nothing in the HTML; a screen reader and the Tab key go through the tiles in the order you wrote them, whatever the layout.
- Inert tiles by default: they are
divs, so nothing is focusable. If a tile leads somewhere, write it as<a class="grm-item">or<button class="grm-item">and add your focus style: the component ships none. - 60 px rows: a label that runs to three lines spills out of its tile (measured: 84 px of text for 58 usable px). Keep labels short or replace the fixed height with
minmax(60px, auto). - Nothing moves: no animation, hence no special handling for reduced motion. White text at weight 600 on a near-black background.
Browser compatibility
CSS grid and container queries, no JavaScript. The three engines tested (Chromium 149, Firefox 151, WebKit 26.5) give the same switches — one column at 219 px, two at 220, three at 300 — and the same 220 px height; at 390 px wide on a phone, the three-column mosaic fits with no horizontal scrolling.
Without @container, tiles stay in a single column at every width. Everything is there, but the stack is tall: 424 px for six tiles.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="fx-0754-root">
<div class="grm-grid">
<div class="grm-item">Featured tile <span class="grm-span">detail shown at 3 columns</span></div>
<div class="grm-item">Tile</div>
<div class="grm-item">Tile</div>
<div class="grm-item">Tile</div>
<div class="grm-item">Tile</div>
<div class="grm-item">Tile</div>
</div>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
Thresholds (CSS — @container grm (min-width: 220px) and (min-width: 300px)) |
220 and 300 px | Go up to 320 and 480 px for wider tiles; a fourth column needs one more rule. |
Featured tile (CSS — .grm-item:first-child in the 300 px rule) |
span 2 across columns and rows |
grid-column: span 3 alone turns it into a full-width band; delete the rule for six equal tiles. |
Row height (CSS — grid-auto-rows) |
60 px | 40 px for a dense list, minmax(60px, auto) to let tiles grow with long text. |
First tile detail (HTML — <span class="grm-span">) |
Hidden under 300 px | Put there what only belongs in the big tile: a value, a precision. |
Tints (CSS — six :nth-child(6n+…) rules) |
Six colours at 15 % opacity | Replace them with a single .grm-item { background: … } rule for a plain mosaic. |
Spacing (CSS — gap, padding of .grm-grid) |
8 px and 12 px | Set padding to 0 if the grid already sits inside a card. |
FAQ
text-decoration: none; on a button, font-family: inherit and cursor: pointer; in both cases a :focus-visible style, which the component does not include.