
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
masonry-simple
Advanced tools
MasonrySimple implements a simple system for placing masonry style elements using CSS Grid. Masonry placement is used for dynamic grids where elements may have different heights and need to be placed neatly without gaps.
A lightweight masonry layout helper built on top of CSS Grid.
init(), refresh(), destroy().yarn add masonry-simple
import MasonrySimple from 'masonry-simple';
const masonry = new MasonrySimple({
container: '.masonry',
});
masonry.init();
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref, shallowRef } from 'vue';
import MasonrySimple from 'masonry-simple';
const masonryRef = ref<HTMLElement | null>(null);
const masonry = shallowRef<MasonrySimple | null>(null);
onMounted(() => {
if (!masonryRef.value) return;
masonry.value = new MasonrySimple({ container: masonryRef.value });
masonry.value.init();
});
onBeforeUnmount(() => {
masonry.value?.destroy();
masonry.value = null;
});
</script>
<template>
<div ref="masonryRef" class="masonry">
<div class="masonry__item">...</div>
<div class="masonry__item">...</div>
</div>
</template>
<div class="masonry">
<div class="masonry__item">
<img src="/img/1.jpg" alt="">
</div>
<div class="masonry__item">
Lorem ipsum
</div>
</div>
.masonry {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
gap: 12px;
}
gridAutoRows: 1pxcontain: layoutalignItems: startdestroy().| Option | Type | Default | Description |
|---|---|---|---|
container | HTMLElement | string | '.masonry' | Target container element or selector. |
masonry.init();
masonry.refresh();
masonry.destroy();
init() is idempotent and does not duplicate observers/listeners.refresh() re-collects grid items and schedules a single layout pass.destroy() cancels scheduled animation frame work, disconnects observers, clears listeners, and resets item styles (gridRowEnd).refresh() after destroy() is a safe no-op.document is unavailable.ResizeObserver / MutationObserver: layout still works via manual refresh().display: none) or zero-size state may produce temporary fallback spans.refresh() manually.refresh().MIT
FAQs
MasonrySimple implements a simple system for placing masonry style elements using CSS Grid. Masonry placement is used for dynamic grids where elements may have different heights and need to be placed neatly without gaps.
The npm package masonry-simple receives a total of 91 weekly downloads. As such, masonry-simple popularity was classified as not popular.
We found that masonry-simple demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.