Moey Icons
No results. Try “dialog”, “dark” or “grid”.
Layout

Griddy

A CSS grid whose items of different heights pack into columns with no holes: photo galleries, pin boards, cards of notes and reviews. Columns come from the grid utilities you already know, the order stays the reading order, and it packs again as pictures load and screens change. New items can arrive with an animation, and items glide to their new place when the layout changes.

<div class="griddy grid-cols-2 md:grid-cols-3 gap-3" data-moey-griddy>
  <a class="gallery-tile" href="lisbon.jpg"><img src="lisbon-small.jpg" alt="Lisbon at dawn" width="800" height="1000"></a>
  <a class="gallery-tile" href="lake.jpg"><img src="lake-small.jpg" alt="A lake up north" width="800" height="560"></a>
  …
</div>

How it works

  1. A grid with columns: .griddy plus the column utilities, grid-cols-2 md:grid-cols-3. Without them it makes as many columns of about 14rem as fit (--mo-griddy-min).
  2. Any items: pictures, cards, notes. Give pictures their width and height so the space is kept before they load.
  3. Moey packs them: each item goes to the column that is shortest so far, at its exact height, so the columns fill with no holes. It packs again when a picture loads, fonts arrive, the window changes, items come and go, or a class changes the columns, the gap or an item's width. It measures each item's real size, so zoom or an entrance animation never makes items overlap.
  4. Reading order stays: items stay in the page's order, roughly left to right, so the keyboard and screen readers go through them sensibly. In browsers with built-in CSS masonry, Moey just uses that.

Cards, not just pictures

Shipped
Order #10421

2 × Linen tote, 1 × Wool beanie

Note

Call the courier before 4 pm.

Review

“The linen tote is perfect. It fits my laptop, a book and lunch. Ordering another one in blue.”

Marco · ★★★★★
Revenue today$4,210
Checklist
  • Pack 12 orders
  • Photograph new bags
  • Update the FAQ
Idea

A small leather tag with the customer's initials?

<div class="griddy gap-4" data-moey-griddy>
  <div class="card">…</div>
  <div class="card">…</div>
</div>

New items arrive

Add data-moey-enter and items added later (infinite scroll, "Load more", a post added by any script) play an entrance, one after another. Pick the effect with its value. Items that only move (sorting, dragging, filters) don't play it, and nothing moves for visitors who turned motion off. Try them:

Note

Call the courier before 4 pm.

Shipped
Order #10421
Idea

A small leather tag with the customer's initials?

<div class="griddy gap-3" data-moey-griddy data-moey-enter="pop">…</div>

<!-- effects: (empty) fade up · fade · rise · drop · zoom · pop · slide · flip · blur · none -->
<!-- data-moey-enter-first: the items already there when the page loads arrive too -->
<!-- your own: [data-moey-enter] > .is-entering { animation: … } (--mo-enter-index: 0, 1, 2… for the stagger) -->

<script>
  Moey.enter(list);           // play it again on every item
  Moey.enter(list, [a, b]);   // or on the ones you give
</script>

It works on any list or grid, not only Griddy: a feed, a list group, a row of cards. The items wait --mo-enter-stagger (60ms, 55ms for pop) one after another.

Gliding

Add .griddy-glide and the items already on the page slide to their new place when the layout changes: an item gets wider, the column count or the gap changes, the window is resized, a filter hides some. An item placed for the first time goes straight to its spot, so new items never fly in from a corner. Try it:

1 · Note

Call the courier before 4 pm.

2 · Review

“Arrived in two days and the stitching is lovely. Already ordered a second one for my sister.”

3 · Restock

40 linen totes.

4 · Checklist
  • Pack 12 orders
  • Photograph new bags
  • Update the FAQ
5 · Idea

A small leather tag with the customer's initials?

6 · Revenue today$4,210
7 · Reminder

Photos for the winter collection on Monday. Bring the gray backdrop.

8 · Order #10422

1 × Wool beanie, gift wrapped.

<div class="griddy griddy-glide grid-cols-2 md:grid-cols-3 gap-3" data-moey-griddy>…</div>

<script>
  item.classList.add('span-2');                         // the others glide out of the way
  grid.classList.replace('md:grid-cols-3', 'md:grid-cols-4');  // a new column count: everything glides
</script>

Wide items, holes filled, drag to arrange

span-2 makes an item two columns wide; .griddy-dense lets later items move up into the holes this leaves (like a packing puzzle). Add data-moey-sortable and people can drag the tiles into their own order. Try it:

<div class="griddy griddy-dense grid-cols-2 md:grid-cols-4 gap-3" data-moey-griddy data-moey-sortable>
  <figure class="gallery-tile span-2" data-id="lisbon">…</figure>
  <figure class="gallery-tile" data-id="lake">…</figure>
  …
</div>

With .griddy-dense the order on screen can differ from the page's. That's fine for pictures, but keep it off when the order matters (news, steps).

Reference

Class / attributeWhat it does
.griddy[data-moey-griddy]Packs its items into columns with no holes
grid-cols-* · md:grid-cols-* · gap-*Columns and spacing (else automatic: --mo-griddy-min, 14rem)
span-2 · span-3An item across two or three columns
.griddy-denseLater items fill holes (order on screen may change)
.griddy-glideItems already there glide to their new place when the layout changes (.4s)
data-moey-enter="…"Items added later arrive, one after another: (empty) fade up · fade · rise · drop · zoom · pop · slide · flip · blur · none. Any list or grid. While they do, they get .is-entering and --mo-enter-index
data-moey-enter-firstThe items already there when the page loads arrive too
--mo-enter-staggerThe wait between items (60ms; 55ms for pop)
.gallery-tile + .gallery-caption / figcaptionA rounded picture tile with a caption on hover (always shown on touch)
Moey.griddy(el).layout()Pack again (after changing items from code; usually automatic)
Moey.enter(list, items?)Play the arrival again, on all items or the ones given
.masonry · .masonry-dense · data-moey-masonry · Moey.masonry()Griddy's earlier names: they still work