Convert Figma logo to code with AI

metafizzy logoisotope

:revolving_hearts: Filter & sort magical layouts

11,041
1,414
11,041
71

Top Related Projects

16,381

:love_hotel: Cascading grid layout plugin

📜 Automatically add next page

67,545

The HTML Presentation Framework

Turbolinks makes navigating your web application faster

10,382

Waypoints is a library that makes it easy to execute a function whenever you scroll to an element.

Quick Overview

Isotope is a JavaScript library for creating dynamic and interactive grid layouts and filtering systems. It allows developers to create responsive, filterable, and sortable layouts for various types of content, such as image galleries, product listings, or portfolio items.

Pros

  • Flexible and customizable layout options (masonry, fitRows, etc.)
  • Smooth animations for filtering and sorting
  • Responsive design support
  • Extensive API for advanced customization

Cons

  • Learning curve for advanced features
  • Performance can be affected with large datasets
  • Requires jQuery as a dependency (for older versions)
  • Limited built-in styling options

Code Examples

  1. Basic initialization:
const iso = new Isotope('.grid', {
  itemSelector: '.grid-item',
  layoutMode: 'masonry'
});
  1. Filtering items:
// Filter items with the 'nature' class
iso.arrange({ filter: '.nature' });
  1. Sorting items:
// Sort items by their 'name' data attribute
iso.arrange({
  sortBy: 'name',
  sortAscending: true
});
  1. Adding and removing items:
// Add new items to the layout
const newItems = [
  { element: newElement1 },
  { element: newElement2 }
];
iso.insert(newItems);

// Remove an item from the layout
iso.remove(itemToRemove);

Getting Started

  1. Install Isotope via npm:
npm install isotope-layout
  1. Import and initialize Isotope in your JavaScript file:
import Isotope from 'isotope-layout';

document.addEventListener('DOMContentLoaded', () => {
  const grid = document.querySelector('.grid');
  const iso = new Isotope(grid, {
    itemSelector: '.grid-item',
    layoutMode: 'masonry'
  });

  // Add event listeners for filtering or sorting if needed
  const filterButtons = document.querySelectorAll('.filter-button');
  filterButtons.forEach(button => {
    button.addEventListener('click', () => {
      const filterValue = button.getAttribute('data-filter');
      iso.arrange({ filter: filterValue });
    });
  });
});
  1. Add the necessary HTML structure and CSS classes to your markup:
<div class="grid">
  <div class="grid-item nature">...</div>
  <div class="grid-item architecture">...</div>
  <div class="grid-item nature">...</div>
  <!-- Add more grid items as needed -->
</div>

Competitor Comparisons

16,381

:love_hotel: Cascading grid layout plugin

Pros of Masonry

  • Simpler and more lightweight, focusing solely on grid layout
  • Easier to implement for basic grid layouts
  • Slightly better performance for simple grid arrangements

Cons of Masonry

  • Limited filtering and sorting capabilities
  • Less flexible for complex layouts and animations
  • Fewer built-in features compared to Isotope

Code Comparison

Masonry:

var grid = document.querySelector('.grid');
var msnry = new Masonry(grid, {
  itemSelector: '.grid-item',
  columnWidth: 200
});

Isotope:

var grid = document.querySelector('.grid');
var iso = new Isotope(grid, {
  itemSelector: '.grid-item',
  layoutMode: 'masonry',
  masonry: {
    columnWidth: 200
  }
});

Both libraries use similar syntax for basic grid initialization. However, Isotope offers additional options for filtering and sorting:

iso.arrange({
  filter: '.metal',
  sortBy: 'name'
});

Masonry is ideal for simple grid layouts, while Isotope provides more advanced features for dynamic content organization. Choose Masonry for lightweight, straightforward grid arrangements, and Isotope for complex, interactive layouts with filtering and sorting capabilities.

📜 Automatically add next page

Pros of Infinite Scroll

  • Specialized for continuous loading of content, ideal for long lists or feeds
  • Simpler implementation for infinite scrolling behavior
  • Lightweight and focused on a single functionality

Cons of Infinite Scroll

  • Limited layout options compared to Isotope's flexible grid arrangements
  • Lacks built-in filtering and sorting capabilities
  • May not be suitable for complex, multi-dimensional layouts

Code Comparison

Infinite Scroll:

let infScroll = new InfiniteScroll('.container', {
  path: '.pagination__next',
  append: '.post',
  history: false,
});

Isotope:

let iso = new Isotope('.grid', {
  itemSelector: '.grid-item',
  layoutMode: 'masonry',
  getSortData: {
    name: '.name',
    category: '[data-category]'
  }
});

Key Differences

Infinite Scroll focuses on dynamically loading content as the user scrolls, while Isotope provides advanced layout and filtering capabilities for existing content. Isotope offers more flexibility in terms of arranging and organizing elements, making it suitable for complex grid layouts and interactive filtering. Infinite Scroll, on the other hand, excels at creating a seamless browsing experience for long lists of content, such as social media feeds or article listings.

67,545

The HTML Presentation Framework

Pros of reveal.js

  • Specifically designed for creating presentations, offering a wide range of features tailored for this purpose
  • Supports markdown content, making it easier to create and maintain presentations
  • Includes a plugin system for extending functionality

Cons of reveal.js

  • Less flexible for general-purpose layout and filtering compared to Isotope
  • May have a steeper learning curve for users not familiar with presentation frameworks

Code Comparison

reveal.js:

Reveal.initialize({
    controls: true,
    progress: true,
    center: true,
    hash: true
});

Isotope:

$('.grid').isotope({
    itemSelector: '.grid-item',
    layoutMode: 'masonry'
});

Key Differences

  • Purpose: reveal.js is for presentations, while Isotope is for dynamic layouts and filtering
  • Functionality: reveal.js offers slide transitions and presentation controls, Isotope provides sorting and filtering of elements
  • Use case: reveal.js is best for creating web-based slideshows, Isotope excels in creating responsive, filterable grid layouts

Similarities

  • Both are JavaScript libraries that manipulate DOM elements
  • Both offer customization options and have active communities
  • Both can be integrated into various web projects to enhance user interfaces

Turbolinks makes navigating your web application faster

Pros of Turbolinks

  • Improves page load performance by replacing the full page load with partial updates
  • Seamlessly integrates with Rails applications, providing a smooth user experience
  • Maintains a consistent JavaScript environment across page changes

Cons of Turbolinks

  • Can introduce complexity when working with JavaScript-heavy applications
  • May require additional configuration for certain third-party libraries to work correctly
  • Limited control over specific elements during page transitions

Code Comparison

Isotope (JavaScript):

$('.grid').isotope({
  itemSelector: '.grid-item',
  layoutMode: 'fitRows'
});

Turbolinks (Ruby on Rails):

# In application.js
//= require turbolinks

# In application.html.erb
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>

Key Differences

  • Isotope focuses on layout and filtering of HTML elements, while Turbolinks aims to speed up page loads in web applications
  • Isotope is a standalone JavaScript library, whereas Turbolinks is primarily used with Ruby on Rails
  • Isotope provides visual effects and animations for element arrangements, while Turbolinks operates behind the scenes to optimize page transitions

Use Cases

  • Isotope: Best for creating dynamic, filterable grid layouts or masonry-style designs
  • Turbolinks: Ideal for improving the performance of traditional server-rendered web applications, especially those built with Ruby on Rails
10,382

Waypoints is a library that makes it easy to execute a function whenever you scroll to an element.

Pros of Waypoints

  • Lightweight and focused on scroll-based events
  • Easy to implement for scroll-triggered animations
  • Supports both vertical and horizontal scrolling

Cons of Waypoints

  • Limited to scroll-based functionality
  • Less versatile for complex layouts or filtering
  • Smaller community and fewer updates compared to Isotope

Code Comparison

Waypoints:

var waypoint = new Waypoint({
  element: document.getElementById('element'),
  handler: function(direction) {
    console.log('Scrolled to waypoint!')
  }
})

Isotope:

var iso = new Isotope('.grid', {
  itemSelector: '.grid-item',
  layoutMode: 'masonry'
});

Key Differences

  • Waypoints focuses on scroll-based events and triggers, while Isotope specializes in dynamic layouts and filtering.
  • Isotope offers more advanced layout options and filtering capabilities, making it better suited for complex grid systems and portfolio-style layouts.
  • Waypoints is more lightweight and easier to implement for simple scroll-based animations, while Isotope provides a more comprehensive solution for dynamic content organization.

Both libraries serve different purposes and can be used together in projects that require both scroll-based events and dynamic layouts. The choice between them depends on the specific needs of your project.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Isotope

Filter & sort magical layouts

See isotope.metafizzy.co for complete docs and demos.

Install

Download

CDN

Link directly to Isotope files on unpkg.

<script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js"></script>
<!-- or -->
<script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.js"></script>

Package managers

npm: npm install isotope-layout --save

Bower: bower install isotope-layout --save

License

Commercial license

If you want to use Isotope to develop commercial sites, themes, projects, and applications, the Commercial license is the appropriate license. With this option, your source code is kept proprietary. Purchase an Isotope Commercial License at isotope.metafizzy.co

Open source license

If you are creating an open source application under a license compatible with the GNU GPL license v3, you may use Isotope under the terms of the GPLv3.

Read more about Isotope's license.

Initialize

With jQuery

$('.grid').isotope({
  // options...
  itemSelector: '.grid-item',
  masonry: {
    columnWidth: 200
  }
});

With vanilla JavaScript

// vanilla JS
var grid = document.querySelector('.grid');
var iso = new Isotope( grid, {
  // options...
  itemSelector: '.grid-item',
  masonry: {
    columnWidth: 200
  }
});

With HTML

Add a data-isotope attribute to your element. Options can be set in JSON in the value.

<div class="grid"
  data-isotope='{ "itemSelector": ".grid-item", "masonry": { "columnWidth": 200 } }'>
  <div class="grid-item"></div>
  <div class="grid-item"></div>
  ...
</div>

By Metafizzy 🌈🐻, 2010–2020

NPM DownloadsLast 30 Days