JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<div class="button-group filter-button-group">
<button data-filter="*">show all</button>
<button data-filter=".green">green</button>
<button data-filter=".blue">blue</button>
<button data-filter=".red">red</button>
<button data-filter=".yellow">yellow</button>
</div>
<div class="grid">
<div class="element-item green">
<div class="attachment-4"></div>
<h3>Title 1</h3>
<h5>Some metadata</h5>
</div>
<div class="element-item yellow">
<div class="attachment-3"></div>
<h3>Title 2</h3>
<h5>Some metadata</h5>
</div>
<div class="element-item blue">
<div class="attachment-2"></div>
<h3>Title 3</h3>
<h5>Some metadata</h5>
</div>
<div class="element-item red">
<div class="attachment-1"></div>
<h3>Title 4</h3>
<h5>Some metadata</h5>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
<script src="https://unpkg.com/isotope-layout@3.0/dist/isotope.pkgd.min.js"></script>
</body>
CSS
.grid {
display: flex;
flex-wrap: wrap;
}
.element-item {
flex-direction: row;
width: calc(100% / 2);
}
.attachment-1 {
width: 400px;
height: 200px;
background-color:red;
}
.attachment-2 {
width: 400px;
height: 200px;
background-color: blue;
}
.attachment-3 {
width: 400px;
height: 200px;
background-color: yellow;
}
.attachment-4 {
width: 400px;
height: 200px;
background-color: green;
}
JavaScript
// init Isotope
var $grid = $('.grid').isotope({
// options
itemSelector: '.element-item',
});
// filter items on button click
$('.filter-button-group').on( 'click', 'button', function() {
var filterValue = $(this).attr('data-filter');
$grid.isotope({ filter: filterValue });
});