Bootstrap 5 masonry layouts display items of varying heights in a Pinterest-style grid. This page covers 4 masonry patterns — CSS columns, Bootstrap data-masonry, text cards and filtered gallery — each ready to use.
Quick Setup
CSS columns masonry needs only Bootstrap 5 CSS. Bootstrap data-masonry needs Masonry.js:
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<!-- Only for Bootstrap data-masonry -->
<script src="https://cdn.jsdelivr.net/npm/masonry-layout@4/dist/masonry.pkgd.min.js"></script>
Key Classes Reference
| Class / Property | What It Does |
|---|---|
column-count: 3 | CSS columns masonry (no JS) |
column-gap: 16px | Gap between columns |
break-inside: avoid | Prevents items splitting across columns |
data-masonry | Bootstrap's built-in masonry (needs Masonry.js) |
.row | Container for Bootstrap masonry |
.col-sm-6 | Column width for Bootstrap masonry |
1. CSS Columns Masonry Layout
The simplest masonry approach using CSS column-count. No JavaScript required.
2. Bootstrap 5 Built-in Masonry
Bootstrap 5.1+ includes a built-in masonry layout via data-masonry attribute. Requires Masonry.js library.
3. Bootstrap 5 Text Card Masonry
Masonry layout with text-only cards of varying heights. Great for blog posts and notes.
4. Bootstrap 5 Filterable Masonry Gallery
Masonry grid with category filter buttons. Click to show only items from that category.
Frequently Asked Questions
Need a Full Bootstrap 5 Admin Dashboard?
Get a complete Angular 21 + Bootstrap 5 dashboard with 50+ components — built by the same team behind BootstrapPlanet.
Browse Templates →Use code FIRST30 for 30% off your first purchase.