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

Filter & sort

Buttons that show only what matches — "Nature", "City" — a search box, and sorting, for any set of items: a gallery, product cards, a team page. Items glide to their new places, a count keeps track, and it works with masonry.

14 photos
<!-- the controls point at the items with a selector -->
<div data-moey-filters="#gallery">
  <button class="btn btn-sm" data-moey-filter="*" aria-pressed="true">All</button>
  <button class="btn btn-sm" data-moey-filter="nature" aria-pressed="false">Nature</button>
  <button class="btn btn-sm" data-moey-sort-by="date" data-moey-sort-dir="desc">Newest</button>
</div>
<input type="search" class="form-control" data-moey-filter-search="#gallery" aria-label="Search photos">
<span data-moey-filter-count="#gallery"></span> photos

<!-- the items carry their tags and the values to sort by -->
<div class="masonry" id="gallery" data-moey-masonry>
  <a class="gallery-tile" href="lake.jpg" data-tags="nature cool" data-date="2026-03-14" data-name="lake">…</a>
  …
  <p class="filter-empty" hidden>No photos match.</p>
</div>

Step by step

  1. Tag the items: data-tags="nature cool" (any words, space-separated). Add the values you want to sort by as data-*: data-date, data-price, data-name…
  2. Add the buttons inside an element with data-moey-filters="#items": data-moey-filter="nature" per tag, data-moey-filter="*" for all. One at a time by default; data-moey-filters-mode="multiple" lets people pick several (an item needs one of them). Chips work as well as buttons.
  3. Sorting buttons in the same group: data-moey-sort-by="price" (+ data-moey-sort-dir="desc"). Numbers sort as numbers and dates as dates.
  4. Search and count (optional): a field with data-moey-filter-search="#items" matches the items' text and tags; data-moey-filter-count="#items" shows "6 of 14". A .filter-empty inside the container appears when nothing matches.
// From code (e.g. tags in the address)
Moey.filter('#gallery', { tags: ['nature'], query: 'lake', sort: 'date', dir: 'desc' });
gallery.addEventListener('moey:filter', (e) => console.log(e.detail.shown, 'of', e.detail.total));

Reference

AttributeWhat it does
data-moey-filters="#items" (+ -mode="multiple")A group of filter / sort buttons for those items
data-moey-filter="tag" · "*"Show items with that tag · show all (the pressed one gets aria-pressed="true")
data-moey-sort-by="date" · data-moey-sort-dir="desc"Sort by the items' data-date · newest / largest first
data-moey-filter-search="#items" · data-moey-filter-count="#items"A search field · a live count
data-tags on items · .filter-emptyThe item's tags · shown when nothing matches
Moey.filter(items, { tags, query, sort, dir }) · event moey:filterFrom code · detail: { shown, total, tags, query }