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

Masonry

Items of different heights packed 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 re-packs as images load and screens change.

<div class="masonry grid-cols-2 md:grid-cols-3 gap-3" data-moey-masonry>
  <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: .masonry plus the column utilities — grid-cols-2 md:grid-cols-3. Without them it makes as many columns of about 14rem as fit (--mo-masonry-min).
  2. Any items: pictures, cards, notes. Give images 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 an image loads, the window changes or items come and go, and 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="masonry gap-4" data-moey-masonry>
  <div class="card">…</div>
  <div class="card">…</div>
</div>

Wide items, holes filled, drag to arrange

span-2 makes an item two columns wide; .masonry-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="masonry masonry-dense grid-cols-2 md:grid-cols-4 gap-3" data-moey-masonry data-moey-sortable>
  <figure class="gallery-tile span-2" data-id="lisbon">…</figure>
  <figure class="gallery-tile" data-id="lake">…</figure>
  …
</div>

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

New items glide in

Add data-moey-enter and items added later (infinite scroll, "Load more", a new post) fade up into place, one after another. Items that only move (sorting, dragging, filters) don't. It works on any list or grid, not only masonry, and nothing moves for visitors who turned motion off.

Note

Call the courier before 4 pm.

Shipped
Order #10421
Idea

A small leather tag with the customer's initials?

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

<!-- data-moey-enter="fade": fade only · ="zoom": grow from 96% -->
<!-- your own: [data-moey-enter] > .is-entering { animation: … } (--mo-enter-index: 0, 1, 2… for a stagger) -->

Reference

Class / attributeWhat it does
.masonry[data-moey-masonry]Packs its items into columns with no holes
grid-cols-* · md:grid-cols-* · gap-*Columns and spacing (else automatic: --mo-masonry-min, 14rem)
span-2 · span-3An item across two or three columns
.masonry-denseLater items fill holes (order on screen may change)
data-moey-enter · ="fade" · ="zoom"Items added later animate in (any list or grid); they get .is-entering and --mo-enter-index while they do
.gallery-tile + .gallery-caption / figcaptionA rounded picture tile with a caption on hover (always shown on touch)
Moey.masonry(el).layout()Pack again (after changing items from code — usually automatic)