packery

The packery layout mode uses a bin-packing algorithm. This is a fancy way of saying “it fills empty gaps.”

Packery is available as a stand-alone layout library. See also: What is the difference between Isotope, Masonry, and Packery?

1
2
3
4
5
6
7
8
9
10
11
12

Edit this demo on CodePen

Install

This layout mode is not included in isotope.pkgd.js and must be installed separately.

Download a packaged source file for packery layout mode:

Install with Bower:

bower install isotope-packery

Install with npm:

npm install isotope-packery

Options

gutter

The space between item elements, both vertically and horizontally.

packery: {
  gutter: 10
}

If set to an Element or Selector String, Isotope will use the width of that element. See Element sizing.

<div class="grid">
  <div class="grid-sizer"></div>
  <div class="gutter-sizer"></div>
  <div class="grid-item"></div>
  <div class="grid-item--width2"></div>
  ...
</div>
.grid-sizer,
.grid-item { width: 22%; }

.gutter-sizer { width: 4%; }
/* spans 2 columns: 22% + 4% + 22% = 48% */
.grid-item--width2 { width: 48%; }
layoutMode: 'packery',
packery: {
  gutter: '.gutter-sizer'
},
itemSelector: '.mini-item',
percentPosition: true

columnWidth

Aligns items to the width of a column of a horizontal grid.

Unlike masonry layout, packery layout does not require columnWidth.

layoutMode: 'packery',
packery: {
  columnWidth: 60
}

If set to an Element or Selector String, Isotope will use the width of that element. See Element sizing. Setting columnWidth with element sizing is recommended if you are using percentage widths.

<div class="grid">
  <div class="grid-sizer"></div>
  <div class="grid-item"></div>
  <div class="grid-item grid-item--width2"></div>
  ...
</div>
.grid-sizer,
.grid-item { width: 20%; }

.grid-item--width2 { width: 40%; }
layoutMode: 'packery',
packery: {
  columnWidth: '.grid-sizer'
},
itemSelector: '.grid-item',
percentPosition: true

rowHeight

Aligns items to the height of a row of a vertical grid.

layoutMode: 'packery',
packery: {
  rowHeight: 60
}

If set to an Element or Selector String, Isotope will use the height of that element. See Element sizing. Setting rowHeight with element sizing is recommended if you are using media queries.

horizontal

Arranges items horizontally instead of vertically.

Set a container height for horizontal layouts.

layoutMode: 'packery',
packery: {
  horizontal: true
}

Stamp

Packery layout can stamp items in place. Packery will layout item elements around stamped elements — even above, unlike Masonry.

layoutMode: 'packery',
itemSelector: '.mini-item',
stamp: '.stamp'