@prof-dev/masonry
TypeScript icon, indicating that this package has built-in type declarations

2.0.12 • Public • Published

CSS Grid masonry polyfill

npm package

A simple, easy-to-use solution for creating masonry-style grids with CSS Grid. This library checks for support of grid-template-rows: masonry in the browser. If unsupported, it automatically adjusts item placement to simulate a masonry layout.

It supports any grid-template-columns configuration and allows flexible use of @media queries to adjust column layouts.

Note: This polyfill does not implement any packing algorithms. The original order of items will be preserved.

Demo

Installation

npm i @prof-dev/masonry

Example

.masonry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, auto));
  align-items: start;
  gap: 12px;
}
const grid = document.querySelector(".masonry-grid");

if (grid !== null) {
  new Masonry(grid);
}

Readme

Keywords

none

Package Sidebar

Install

npm i @prof-dev/masonry

Weekly Downloads

27

Version

2.0.12

License

ISC

Unpacked Size

237 kB

Total Files

27

Last publish

Collaborators

  • profesor08